public async Task Get_Category_ReturnsNextCategoryId(long expectedId) { // Arrange var query = new GetNextCategoryIdQuery(); var databaseContextOptions = new DbContextOptionsBuilder <DatabaseContext>() .UseInMemoryDatabase("kb-pundit") .Options; var databaseContext = new DatabaseContext(databaseContextOptions); var categoryCommandHandler = new CategoryCommandHandler(databaseContext); var categoryQueryHandler = new CategoryQueryHandler(databaseContext); var circuitBreaker = new CircuitBreaker(TaskScheduler.Default, 5, TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(1000)); var controller = new CategoryController(circuitBreaker, categoryCommandHandler, categoryQueryHandler); // Act var result = await controller.GetNextCategoryIdAsync(query); // Assert Assert.AreEqual(expectedId, result.Id); }
public async Task <GetNextCategoryIdQueryResult> GetNextCategoryIdAsync( [FromQuery] GetNextCategoryIdQuery query, CancellationToken cancellationToken = default(CancellationToken)) { return(await _categoryQueryHandler.ExecuteAsync(query, cancellationToken)); }