public void ItemsCountTest() { int?itemsCount = 0; using (AppBlocksDbContext dbContext = Factory.CreateDbContext()) { itemsCount = dbContext.Items?.Count(); } Assert.IsNotNull(itemsCount > 0, $"Count:{itemsCount}"); }
public void HomeTest() { Item item = null; using (AppBlocksDbContext dbContext = Factory.CreateDbContext()) { item = dbContext?.Items?.FirstOrDefault(i => i.Name == "Home"); } Assert.IsNotNull(item, "no one's home"); }
public void SystemTest() { Item item = null; using (AppBlocksDbContext dbContext = Factory.CreateDbContext()) { item = dbContext?.Items?.FirstOrDefault(i => i.Name == "System"); } Assert.IsNull(item, "all systems are not go"); }
public void RootFullPathTest() { Item item = null; using (AppBlocksDbContext dbContext = Factory.CreateDbContext()) { item = dbContext.Items.OrderBy(i => i.FullPath).FirstOrDefault(); } Assert.IsNotNull(item); Assert.IsTrue(string.IsNullOrEmpty(item.FullPath), $"FullPath:{item.FullPath}"); }
static void Main(string[] args) { //await (CreateHostBuilder(args)).Build(); //var host = await CreateHostBuilder(args).Build(); var host = CreateHostBuilder(args).Build(); //Factory.CreateDbIfNotExists(host).Result; host.RunAsync(); //host.Run(); using (AppBlocksDbContext dbContext = Factory.CreateDbContext()) { var Migrate = false; if (Migrate) { dbContext.Database.Migrate(); } //sc.Items.AddRange //( // new Item { Name = "Home" } //); //sc.SaveChanges(); Console.WriteLine($"Items found:{dbContext.Items.Count()}"); var root = dbContext.Items.OrderBy(i => i.FullPath).FirstOrDefault(); Console.WriteLine($"Root:{root?.Name}"); var home = dbContext.Items.FirstOrDefault(i => i.Name == "Home"); Console.WriteLine($"Home:{home?.Name}"); using (var _destinationContext = Factory.CreateDbContext()) { home = _destinationContext.Items.FirstOrDefault(i => i.Name == "Home"); Console.WriteLine($"Destination:{home?.Name}:{home?.Id}"); } var Sync = false; if (Sync) { Console.Write(Factory.Sync()); Console.Write("\r\n\r\nPress any key to exit."); Console.ReadKey(); } } }