コード例 #1
0
        public async Task ExistsShouldCheckWhetherProducTypetWithGivenNameExists(bool exists)
        {
            const string name = nameof(name);

            ApplicationDbContext dbContext = this.GetNewDbContext();

            IRepository <ProductType> repository = new EfRepository <ProductType>(dbContext);

            IProductTypeService service = new ProductTypeService(repository);

            if (exists)
            {
                dbContext.ProductTypes.Add(new ProductType
                {
                    Name = name,
                });

                await dbContext.SaveChangesAsync();
            }

            bool result = service.Exists(name);

            Assert.Equal(exists, result);
        }