예제 #1
0
        public async Task EditCategory()
        {
            // Arrange
            var db = this.GetDatabase();

            var category = new Category {
                Id = 1, Name = "test", PictureUrl = "https://test"
            };

            db.Add(category);

            await db.SaveChangesAsync();

            var adminCategoryService = new AdminCategoryService(db);
            // Act

            await adminCategoryService.EditAsync(1, "changed", "https://changed");

            await db.SaveChangesAsync();

            var result = adminCategoryService.ById(1);


            // Assert
            result
            .Name
            .Should()
            .Equals("changed");
        }
예제 #2
0
        public async Task CategoryById()
        {
            // Arrange
            var db = this.GetDatabase();

            var firstCategory = new Category {
                Id = 1, Name = "First"
            };
            var secondCategory = new Category {
                Id = 2, Name = "Second"
            };
            var thirdCategory = new Category {
                Id = 3, Name = "Third"
            };

            db.AddRange(firstCategory, secondCategory, thirdCategory);

            await db.SaveChangesAsync();

            var adminCategoryService = new AdminCategoryService(db);
            // Act
            var result = adminCategoryService.ById(3);


            // Assert
            result
            .Name
            .Should()
            .Equals("Third");
        }
예제 #3
0
        public async Task ByIdShouldReturnTheItemThatIsCalled()
        {
            // Arrange
            //Mapper.Initialize(config => config.AddProfile<AutoMapperProfile>());
            var db = this.Context;

            this.PopulateData(db);

            var categoriesService = new AdminCategoryService(db);
            var categoryId        = 1;

            // Act
            var result = await categoriesService.ById(categoryId);

            // Assert
            result
            .Should()
            .NotBe(null);

            result
            .Name
            .Should()
            .Be("firstOne");
        }