public async Task GetAllCategoriesTest()
        {
            var handler = new GetAllCategoriesQueryHandler(_context, _mapper);
            var result  = await handler.Handle(new GetAllCategoriesQuery(),
                                               CancellationToken.None);

            result.Count().ShouldBe(6);
            result.ShouldBeOfType <List <CategoryViewModel> >();
        }
예제 #2
0
        public async Task GetAllCategoriesHandler_Returns_Categories()
        {
            var message        = new GetAllCategoriesQuery();
            var handlerContext = TestContext.CreateHandlerContext <IEnumerable <CategoryViewModel> >(RequestDbContext);
            var handler        = new GetAllCategoriesQueryHandler(handlerContext);

            var result = await handler.Handle(message, CancellationToken.None);

            Assert.NotEmpty(result.Payload);
        }
예제 #3
0
        public async Task GetAllCategoriesTest()
        {
            // Arrange
            var sut = new GetAllCategoriesQueryHandler(_context, _mapper);

            // Act
            var result = await sut.Handle(new GetAllCategoriesQuery(), CancellationToken.None);

            // Assert
            Assert.IsType <List <CategoryDetailDto> >(result);
            Assert.Equal(3, result.Count);
        }
예제 #4
0
        public async Task GetAllCategoriesQueryTestAsync()
        {
            GetAllCategoriesQuery        request = new GetAllCategoriesQuery();
            GetAllCategoriesQueryHandler handler = new GetAllCategoriesQueryHandler(_fixture.Context);
            var expectedResult = await handler.Handle(request, new CancellationToken());

            var expecteResultIds = expectedResult.Select(c => c.Id);

            Assert.Equal(expecteResultIds, new List <int> {
                1, 2, 3
            });
        }