
Explore unit testing with xunit for dotnet core across platforms, and learn testing patterns, data driven testing, mocking, and a real-time three-tier web API.
Explore unit testing as a development-time approach that checks the quality of the smallest component of an application, combining unit and testing to validate each part.
Uncover how unit testing verifies that each unit satisfies requirements and catches bugs early before production, enabling design and testing to go hand in hand during the software development cycle.
Explore the three main C# testing frameworks, with a focus on xUnit, its simplicity, and its integration with Visual Studio as an open source library under the .NET foundation.
Create your first unit test in Visual Studio by building a calculator class library with an add method, then test it using xUnit with arrange-act-assert and the test explorer.
Understand how to structure unit tests using arrange, act, and assert to initialize variables, perform the action, and verify the expected behavior of each component.
Learn unit testing in .NET by using the fact attribute and running tests with dotnet test, then verify a mail address is valid with arrange, act, and Asserttrue.
Perform a practical demo of unit testing with xunit in a dotnet six project, using arrange-act-assert to test get grades percentage and argument exceptions for null or zero.
Explore test naming conventions, using a three-part format: function name, given information, and expected behavior. Include examples like get grade, add employee underscore given employee details, and null throws error.
Learn how refactoring systematically improves code without changing external behavior, using incremental tests after each change to reduce complexity in the service layer and verify changes through unit automation.
Explore test doubles in unit testing, detailing fake, mocks, and stubs, and review testable techniques and their use in validating component functionality.
Explain fakes as shortcut in-memory implementations used in unit tests to avoid database calls, not an integration test.
Create a unit test project that uses a fake user repository to test get all users without a database, validating three inserted users via not-null and count checks.
A stub provides predefined data to answer test calls, avoiding real data and side effects; grade system stub uses a hardcoded list of A grades to fetch a student's grade.
Explore practical use of stubs in unit testing by returning a hard coded true for the is authenticated method, enabling tests to trigger downstream actions without real dependencies.
Explore how mocks simulate dependencies by registering calls and providing dynamic test responses. Verify expected actions with mocks and set up behavior, such as returning true for specific inputs.
Explore practical unit testing with mocks by faking dependencies such as IBookService and IEmailSender in AccountService, covering setup, returns, verification, and exception scenarios.
Learn when to use fakes, stubs, and mocks in unit testing. Use fakes for reusable concrete implementations that mimic real behavior, stubs for hard-coded responses, and mocks for dynamic interactions.
Learn data driven testing by supplying multiple input parameters to a single test with inline data. Compare fact and theory attributes to create parameterized tests using inline data.
Demonstrate inline data in unit tests by showing multiple test executions for a two-parameter add method, using theory, and assert equals for expected results with inline data.
Use class data to supply non-constant values for data-driven tests via a class data attribute. Prepare the data in an IEnumerable class so xUnit can feed it to test method.
Create a calculator test data class implementing IEnumerable<object> to supply test cases with yield return; run three cases and show an error when four parameters are provided.
Discover how the member data attribute drives data-driven theories by fetching data from static properties or methods, and loading data from an IEnumerable property on the test class.
Explore practical usage of member data for data-driven unit tests by defining static enumerable data sources, either inline or via a data provider method, and verify parallel test execution.
Explore how mocking injects dependencies to simulate external systems, enabling unit tests to control responses from services, databases, and file handlers, using NuGet mocks in dotnet projects.
Explore XUnit terminologies, including fact, assert.equal, assert.notEqual, assert.false, and assert.true. Learn how null, not null, and throws are used to test component behavior and exception scenarios, enabling safer refactors.
Explore mocking and unit testing for a swagger-based web API, examining a three-tier app with infrastructure, core, and service projects, and its repository pattern and department and employee domain entities.
Learn to unit test the controller and service layers of a three-tier web API, using mocks to simulate get, update, and delete operations on department data.
Demonstrate controller level testing for post api by validating model state, injecting blank department fields, and asserting a 400 bad request through object result casting and assertions.
Learn how to debug unit test cases, validate model state and status codes, and use mocking to test controllers and prepare service-layer tests with mocked databases.
Master service level testing with moq by mocking the department repository to test the department service’s get details by id, covering the happy path and zero-id null scenarios.
Explore unit testing of a department service with moq, covering save with null department throwing an argument exception and update using arrange, act, assert against a mock repository.
Learn to implement a fake repository that satisfies the IRepository interface, using an in-memory department list to support add, remove, find, and update operations for service-level unit testing.
Create and run a test for a fake department service with a fake repository, initialize data, verify get details, and compare mock versus fake approaches in three-tier web API.
Refactor poisoned code by decoupling date time dependency in a static get time of day method to enable reliable unit tests with predefined data.
Refactor the tightly coupled get time of the day by parameterizing with a DateTime, enabling reliable unit tests. Demonstrate a simple arrange–act–assert test to verify morning time.
Explore poisoned tests caused by coupling to a data source and date time, and demonstrate refactoring by using input parameter for date time to uphold single responsibility principle.
Learn to write maintainable unit test cases for small, independent components with self-explanatory names, parallel execution, and mocking of external services with in-memory data.
All dotnet developers looking to develop new skills and take their career to the next level – this is the course to help you get there!
This course is focused on the Unit Testing .NET Core / .NET 6 Projects with xUnit .net, an open-source unit testing tool for .Net Framework and .Net Core/6 applications and the standard tool for unit testing C# VB. NET and F# projects in Visual Studio.
Overall, this course is for everyone and for all the levels as it is designed to understand and learn about the technicalities in unit test cases.
Being a proficient and confident user of this tool will allow you to execute essential .NET core development tasks.
In this course, I will teach you:
The basics of the xUnit .net
Learn unit testing from scratch
How to write organized Unit Test Cases
How to use data-driven testing capabilities
Run and Debug Unit Tests
How to use mocking frameworks, including MoQ
How to test legacy code
How to write unit tests for .NET Core Web APIs
Implement unit testing in N-tier real world web application project using XUnit
Questions are always welcome from students and can be asked in the Q&A section of the course. I endeavor to respond to these quickly to create an engaging learning environment for my students.