public void AllShouldReturnListWithAllSuppliers() { var options = new DbContextOptionsBuilder <BookStoreDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; // var dbContext = new BookStoreDbContext(options); var supplierService = new SuppliersService(dbContext); var suppliers = new List <Supplier> { new Supplier() { Name = "Speedy", PriceToOffice = 4.99M, PriceToHome = 5.99M }, new Supplier() { Name = "Eccont", PriceToOffice = 5.99M, PriceToHome = 6.99M }, }; dbContext.Suppliers.AddRange(suppliers); dbContext.SaveChanges(); var listWithSuppliers = supplierService.All().ToList(); Assert.True(listWithSuppliers.Count == 2); }
public void AllShouldReturnAllSuppliers() { var options = new DbContextOptionsBuilder <XeonDbContext>() .UseInMemoryDatabase(databaseName: "All_Supplier_Database") .Options; var dbContext = new XeonDbContext(options); var suppliersService = new SuppliersService(dbContext); var suppliers = new List <Supplier> { new Supplier { Name = "Econt", IsDefault = true }, new Supplier { Name = "DHL", IsDefault = false }, }; dbContext.Suppliers.AddRange(suppliers); dbContext.SaveChanges(); Assert.Equal(2, suppliersService.All().Count()); }