示例#1
0
        public void TestLocationLineRemoval()
        {
            var options = new DbContextOptionsBuilder <P0_DbContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .Options;

            using (var context = new P0_DbContext(options))
            {
                context.Remove(context.locationLines.SingleOrDefault(x => x.LocationLineId == 1));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                Assert.Null(context.locationLines.SingleOrDefault(x => x.LocationId == 1));
            }
        }
示例#2
0
        public void TestLocationLineCreation()
        {
            var options = new DbContextOptionsBuilder <P0_DbContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .Options;

            using (var context = new P0_DbContext(options))
            {
                context.Add(new LocationLine(1, 1, 1, 1));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                var locationLine = context.locationLines.SingleOrDefault(x => x.LocationLineId == 1);
                Assert.Equal(1, 1);
            }
        }
示例#3
0
        public void TestOrderCreation()
        {
            var options = new DbContextOptionsBuilder <P0_DbContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .Options;

            using (var context = new P0_DbContext(options))
            {
                context.Add(new Order(1, 1, DateTime.Now, 1));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                var order = context.orders.SingleOrDefault(x => x.OrderId == 1);
                Assert.Equal(1, 1);
            }
        }
示例#4
0
        public void TestLocationCreation()
        {
            var options = new DbContextOptionsBuilder <P0_DbContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .Options;

            using (var context = new P0_DbContext(options))
            {
                context.Add(new Location("Test", "Test", "Test", "Test"));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                var location = context.locations.SingleOrDefault(x => x.Address == "Test").Address;
                Assert.Equal("Test", location);
            }
        }
示例#5
0
        public void TestCustomerCreation()
        {
            var options = new DbContextOptionsBuilder <P0_DbContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .Options;

            using (var context = new P0_DbContext(options))
            {
                context.Add(new Customer("Test", "Best"));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                var customer = context.customers.SingleOrDefault(x => x.FirstName == "Test").FirstName;
                Assert.Equal("Test", customer);
            }
        }