示例#1
0
        public void FindAllBrandsShouldReturnOnlyBrandsWhereIsDeletedIsFalse()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: $"FindAllBrandsShouldReturnOnlyBrandsWhereIsDeletedIsFalse_Brand_Database")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var mapper = this.SetUpAutoMapper();

            var brandService = new BrandsService(dbContext, mapper);

            var brandName  = Guid.NewGuid().ToString();
            var brandName1 = Guid.NewGuid().ToString();
            var brandName2 = Guid.NewGuid().ToString();
            var model      = new CreateBrandBindingModel {
                Name = brandName
            };
            var model1 = new CreateBrandBindingModel {
                Name = brandName1
            };
            var model2 = new CreateBrandBindingModel {
                Name = brandName2
            };

            brandService.CreateBrand(model);
            brandService.CreateBrand(model1);
            brandService.CreateBrand(model2);
            brandService.RemoveBrand(model);
            brandService.RemoveBrand(model1);

            var brands = brandService.FindAllBrands();

            Assert.True(brands.Count == 1);
        }
示例#2
0
        public void RemoveBrandShouldSetIsDeletedToTrue()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: $"RemoveBrandShouldSetIsDeletedToTrue_Brand_Database")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var mapper = this.SetUpAutoMapper();

            var brandService = new BrandsService(dbContext, mapper);

            var brandName  = Guid.NewGuid().ToString();
            var brandName1 = Guid.NewGuid().ToString();
            var model      = new CreateBrandBindingModel {
                Name = brandName
            };
            var model1 = new CreateBrandBindingModel {
                Name = brandName1
            };

            brandService.CreateBrand(model);
            brandService.CreateBrand(model1);
            brandService.RemoveBrand(model);
            var brand1 = brandService.CreateBrand(model);

            Assert.NotNull(brand1);
            Assert.True(brand1.IsDeleted == false);
        }
示例#3
0
        public void RemoveBrandShouldReturnNullIfBrandIsNull()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: $"RRemoveBrandShouldReturnNullIfBrandIsNull_Brand_Database")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var mapper = this.SetUpAutoMapper();

            var brandService = new BrandsService(dbContext, mapper);

            var brandName = Guid.NewGuid().ToString();
            var model     = new CreateBrandBindingModel {
                Name = brandName
            };

            var brand = brandService.RemoveBrand(model);

            Assert.Null(brand);
        }