コード例 #1
0
        public async void AddCustomerToDatabaseTest()
        {
            var options = new DbContextOptionsBuilder <CheapWareContext>()
                          .UseInMemoryDatabase(databaseName: "AddCustomersFromDatabase")
                          .Options;


            using (var context = new CheapWareContext(options))
            {
                var service = new ComputerRepo(context);
                service.AddCustomer(new Customer {
                    CustomerName = "test name", Address = "test address", UserName = "******"
                });
                await service.Save();
            }


            using (var context = new CheapWareContext(options))
            {
                Assert.Equal(1, context.Customers.Count());
                Assert.Equal("test name", context.Customers.Single().CustomerName);
            }
        }