Ejemplo n.º 1
0
        public void TestOrderRemoval()
        {
            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();
                context.Remove(context.orders.SingleOrDefault(x => x.OrderId == 1));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                Assert.Null(context.orders.SingleOrDefault(x => x.OrderId == 1));
            }
        }
Ejemplo n.º 2
0
        public void TestCustomerRemoval()
        {
            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();
                context.Remove(context.customers.SingleOrDefault(x => x.FirstName == "Test"));
                context.SaveChanges();
            }

            using (var context = new P0_DbContext(options))
            {
                Assert.Null(context.customers.SingleOrDefault(x => x.FirstName == "Test"));
            }
        }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
            }
        }