Exemple #1
0
        public async Task GetCategoriesListTest()
        {
            var handler = new GetCategoriesListQueryHandler(_mapper, _mockCategoryRepository.Object);
            var result  = await handler.Handle(new GetCategoriesListQuery(), CancellationToken.None);

            result.ShouldBeOfType <List <CategoryListVm> >();
            result.Count.ShouldBe(4);
        }
        public async Task GetCategoriesTest()
        {
            var queryHandler = new GetCategoriesListQueryHandler(_context, _mapper);

            var result = await queryHandler.Handle(new GetCategoriesListQuery(), CancellationToken.None);

            result.ShouldBeOfType <CategoriesListVM>();

            result.Categories.Count.ShouldBe(2);
        }
        public GetCategoriesListQueryHandlerTests()
        {
            var configurationProvider = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <MappingProfile>();
            });

            _mapper  = configurationProvider.CreateMapper();
            _handler = new GetCategoriesListQueryHandler(_categoryRepositoryMock.Object, _mapper);
        }
Exemple #4
0
        public async Task GetCategoriesListTest()
        {
            // Arrange
            var sut = new GetCategoriesListQueryHandler(_context, _mapper);

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

            // Assert
            Assert.IsType <List <CategoryListDto> >(result);
            Assert.Equal(3, result.Count);
        }
Exemple #5
0
        public async Task GetAllCategoriesList_ShouldReturn_NotEmpty()
        {
            var sut = new GetCategoriesListQueryHandler(_context, _mapper);

            var result = await sut.Handle(new GetCategoriesListQuery(), CancellationToken.None);

            var itemCount = _context.Categories.Count();


            result.Items.Should().NotBeEmpty();
            result.Items.Count.Should().Be(itemCount);
            result.Items.FirstOrDefault(x => x.Id != 0).Should().NotBeNull();
        }