Exemple #1
0
        public async Task Update()
        {
            var fixture = new DbFixtureInitDb();

            fixture.Initalize();

            await fixture.ExecuteBatchAsync("Update");

            using (var orderContext = fixture.CreateContext())
            {
                var category = orderContext.Categories.Single(t => t.Name == "sombrero jacket");
                Assert.Equal("jackets", orderContext.Categories.Single(t => t.Id == category.ParentId).Name);

                Assert.Equal(4, orderContext.Customers.Count());
                Assert.Equal(3, orderContext.Orders.Count());
                Assert.Equal(7, orderContext.OrderItems.Count());

                var order1 = orderContext.Orders.Include(t => t.Items).Single(t => t.Id == 1);
                Assert.Equal("New Order 1", order1.Name);
                Assert.Equal("New Product order 1 item 3", order1.Items.Single(t => t.Id == 3).Product);

                Assert.Equal(Sex.Female, orderContext.Customers.Single(c => c.Id == 1).Sex);
                Assert.Equal(null, orderContext.Customers.Single(c => c.Id == 2).Sex);
            }
        }
Exemple #2
0
        public async Task Delete()
        {
            var fixture = new DbFixtureInitDb();

            fixture.Initalize();

            await fixture.ExecuteBatchAsync("Delete");

            using (var orderContext = fixture.CreateContext())
            {
                Assert.Equal(5, orderContext.Categories.Count());
                Assert.Equal(4, orderContext.Customers.Count());
                Assert.Equal(2, orderContext.Orders.Count());
                Assert.Equal(3, orderContext.OrderItems.Count());

                var order1 = orderContext.Orders.Include(t => t.Items).Single(t => t.Name == "Order 1");
                Assert.Equal("Product order 1 item 3", order1.Items.Single().Product);
            }
        }