예제 #1
0
        public async Task ShouldGetAllCategories()
        {
            var categories = new List <Category>
            {
                new Category("Test Category #1", fixture.UserId),
                new Category("Test Category #2", fixture.UserId),
            };

            await fixture.ExecuteDbContext(db =>
            {
                db.Categories.AddRange(categories);
                return(db.SaveChangesAsync());
            });

            var mapper       = new CategoryServiceMapper();
            var categoryDtos = categories.Select(mapper.MapToCategoryDto).ToArray();

            var response = await fixture.RequestSender.GetAsync("categories");

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            var responseJson = await response.Content.ReadAsStringAsync();

            var returnedCategories = fixture.Deserialize <CategoryDto[]>(responseJson);

            returnedCategories.Should().NotBeEmpty();
            foreach (var categoryDto in categoryDtos)
            {
                returnedCategories.Should().ContainEquivalentOf(categoryDto);
            }
        }
예제 #2
0
        public void MapToCategoryDto_Category_ValidDto()
        {
            //arrange
            var authorId     = 5;
            var categoryName = "category";
            var category     = new Category(categoryName, authorId);
            int categoryId   = 3;

            category.Id = categoryId;
            var expectedDto = new CategoryDto
            {
                Id   = categoryId,
                Name = categoryName
            };
            //act
            var mapper = new CategoryServiceMapper();
            var dto    = mapper.MapToCategoryDto(category);

            //assert
            dto.Should().BeEquivalentTo(expectedDto);
        }
예제 #3
0
 public CategoryOrchestrator(CategoryService categoryService, CategoryServiceMapper categoryMapper)
 {
     this.categoryService = categoryService;
     this.categoryMapper  = categoryMapper;
 }