예제 #1
0
        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);
        }
예제 #2
0
 public async Task <GetNextCategoryIdQueryResult> GetNextCategoryIdAsync(
     [FromQuery] GetNextCategoryIdQuery query, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await _categoryQueryHandler.ExecuteAsync(query, cancellationToken));
 }