December 2019
Intermediate to advanced
510 pages
11h 33m
English
The xUnit framework is the preferred choice for testing .NET applications and services. The framework also provides some utilities to extend its capabilities and to implement a more maintainable testing code. It is possible to extend the DataAttribute class exposed by the xUnit.Sdk namespace to perform custom operations inside our attributes. For example, let's suppose that we create a new custom DataAttribute to load test data from a file, as follows:
namespace Catalog.API.Tests.Controllers{ public class ItemControllerTests : IClassFixture<InMemoryApplicationFactory<Startup>> { ... [Theory] [LoadData( "item")] public async Task get_by_id_should_return_right_data(Item request) { var client = _factory.CreateClient(); ...