public async Task Update() { var fixture = new DbFixtureInitDb(); await fixture.Initalize(); Container container = DbFixtureInitDb.CreateContainer(0); await Update(container); await container.SaveChangesAsync(SaveChangesOptions.BatchWithSingleChangeset); container = DbFixtureInitDb.CreateContainer(0); var category = await container.Categories.Where(t => t.Name == "sombrero jacket").SingleAsync(); Assert.Equal("jackets", (await container.Categories.Where(t => t.Id == category.ParentId).SingleAsync()).Name); Assert.Equal(4, (await container.Customers.ToListAsync()).Count); Assert.Equal(4, (await container.Orders.ToListAsync()).Count); Assert.Equal(7, (await container.OrderItems.ToListAsync()).Count); var order1 = await container.Orders.ByKey(1).Expand(t => t.Items).GetValueAsync(); 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, (await container.Customers.ByKey("RU", 1).GetValueAsync()).Sex); Assert.Equal(null, (await container.Customers.ByKey("EN", 1).GetValueAsync()).Sex); }
public async Task Add() { var fixture = new DbFixtureInitDb(true); await fixture.Initalize(); Container container = DbFixtureInitDb.CreateContainer(0); Add(container); await container.SaveChangesAsync(SaveChangesOptions.BatchWithSingleChangeset); container = DbFixtureInitDb.CreateContainer(0); Assert.Equal(8, (await container.Categories.ToListAsync()).Count); Assert.Equal(4, (await container.Customers.ToListAsync()).Count); Assert.Equal(3, (await container.Orders.ToListAsync()).Count); Assert.Equal(7, (await container.OrderItems.ToListAsync()).Count); var category = await container.Categories.Where(t => t.Name == "jackets").SingleAsync(); Assert.Equal("clothes", (await container.Categories.Where(t => t.Id == category.ParentId).SingleAsync()).Name); Assert.Equal(2, (await container.Categories.Where(t => t.ParentId == category.Id).ToListAsync()).Count); var order1 = await container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order 1").SingleAsync(); Assert.Equal(3, order1.Items.Count()); var order2 = await container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order 2").SingleAsync(); Assert.Equal(2, order2.Items.Count()); var order3 = await container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order unknown").SingleAsync(); Assert.Equal(2, order3.Items.Count()); }
public Task Update() { var fixture = new DbFixtureInitDb(); fixture.Initalize(); Container container = DbFixtureInitDb.CreateContainer(); Update(container); container.SaveChanges(SaveChangesOptions.BatchWithSingleChangeset); container = DbFixtureInitDb.CreateContainer(); var category = container.Categories.Where(t => t.Name == "sombrero jacket").Single(); Assert.Equal("jackets", container.Categories.Where(t => t.Id == category.ParentId).Single().Name); Assert.Equal(4, container.Customers.Count()); Assert.Equal(3, container.Orders.Count()); Assert.Equal(7, container.OrderItems.Count()); var order1 = container.Orders.ByKey(1).Expand(t => t.Items).GetValue(); 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, container.Customers.ByKey(1).GetValue().Sex); Assert.Equal(null, container.Customers.ByKey(2).GetValue().Sex); return(Task.CompletedTask); }
public async Task Delete() { var fixture = new DbFixtureInitDb(); await fixture.Initalize(); Container container = DbFixtureInitDb.CreateContainer(0); Delete(container); await container.SaveChangesAsync(SaveChangesOptions.BatchWithSingleChangeset); container = DbFixtureInitDb.CreateContainer(0); Assert.Equal(5, (await container.Categories.ToListAsync()).Count); Assert.Equal(4, (await container.Customers.ToListAsync()).Count); Assert.Equal(2, (await container.Orders.ToListAsync()).Count); Assert.Equal(3, (await container.OrderItems.ToListAsync()).Count); var order1 = await container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order 1").SingleAsync(); Assert.Equal("Product order 1 item 3", order1.Items.Single().Product); }
public Task Add() { var fixture = new DbFixtureInitDb(true); fixture.Initalize(); Container container = DbFixtureInitDb.CreateContainer(); Add(container); container.SaveChanges(SaveChangesOptions.BatchWithSingleChangeset); container = DbFixtureInitDb.CreateContainer(); Assert.Equal(8, container.Categories.Count()); Assert.Equal(4, container.Customers.Count()); Assert.Equal(3, container.Orders.Count()); Assert.Equal(7, container.OrderItems.Count()); var category = container.Categories.Where(t => t.Name == "jackets").Single(); Assert.Equal("clothes", container.Categories.Where(t => t.Id == category.ParentId).Single().Name); Assert.Equal(2, container.Categories.Where(t => t.ParentId == category.Id).Count()); var order1 = container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order 1").Single(); Assert.Equal(3, order1.Items.Count()); var order2 = container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order 2").Single(); Assert.Equal(2, order2.Items.Count()); var order3 = container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order unknown").Single(); Assert.Equal(2, order3.Items.Count()); return(Task.CompletedTask); }
public Task Delete() { var fixture = new DbFixtureInitDb(); fixture.Initalize(); Container container = DbFixtureInitDb.CreateContainer(); Delete(container); container.SaveChanges(SaveChangesOptions.BatchWithSingleChangeset); container = DbFixtureInitDb.CreateContainer(); Assert.Equal(5, container.Categories.Count()); Assert.Equal(4, container.Customers.Count()); Assert.Equal(2, container.Orders.Count()); Assert.Equal(5, container.OrderItems.Count()); var order1 = container.Orders.Expand(t => t.Items).Where(t => t.Name == "Order 1").Single(); Assert.Equal("Product order 1 item 3", order1.Items.Single().Product); return(Task.CompletedTask); }