protected static void SeedDatabase(FluentModel context) { User usr1 = new User() { UserId = 1, Name = "Gary Adkins", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; User usr2 = new User() { UserId = 2, Name = "Tim Gordon", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; User usr3 = new User() { UserId = 3, Name = "Jack Jameson", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; User usr4 = new User() { UserId = 4, Name = "Bill Tompson", Note = "note note note", Email = "*****@*****.**", Income = 10000.324m }; Group administratorsGroup = new Group() { GroupId = 1, Name = "Administrators", Description = "admin group description", }; administratorsGroup.UsersInGroup.Add(usr1); administratorsGroup.UsersInGroup.Add(usr2); Group coreUsersGroup = new Group() { GroupId = 2, Name = "Core users", Description = "core users description" }; coreUsersGroup.UsersInGroup.Add(usr3); coreUsersGroup.UsersInGroup.Add(usr4); context.Add(administratorsGroup); context.Add(coreUsersGroup); context.SaveChanges(); }
public void TestInit() { base.BaseTestInit(); BaseTestClass.contextFactory.SetContextMode(ContextMode.OfflineMode); using (FluentModel context = BaseTestClass.contextFactory.GetContext()) { BaseTestClass.EnsureDatabase(context); BaseTestClass.ClearDatabase(context); //clear the artificial type DeleteOperation context.GetAll(DeleteOperationDefinition.DeleteOperationFullTypeName).DeleteAll(); } this.offlineContext = BaseTestClass.contextFactory.GetContext(); }
public FluentModel GetContext() { FluentModel context = null; if (this.contextMode == ContextMode.OnlineMode) { context = new FluentModel(ONLINE_STORAGE_CONNECTION_NAME, onlineBackendConfig, onlineMetadataSource, this.contextMode); } else { context = new FluentModel(OFFLINE_STORAGE_CONNECTION_NAME, offlineBackendConfig, offlineMetadataSource, this.contextMode); } return context; }
public void ContextSwitchTeststInit() { //prepare the online storage base.BaseTestInit(); //prepare the offline storage BaseTestClass.contextFactory.SetContextMode(ContextMode.OfflineMode); using (FluentModel context = BaseTestClass.contextFactory.GetContext()) { BaseTestClass.EnsureDatabase(context); BaseTestClass.ClearDatabase(context); BaseTestClass.SeedDatabase(context); context.GetAll(DeleteOperationDefinition.DeleteOperationFullTypeName).DeleteAll(); } BaseTestClass.contextFactory.SetContextMode(ContextMode.OnlineMode); this.lockContext = BaseTestClass.contextFactory.GetContext(); this.onlineContext = BaseTestClass.contextFactory.GetContext(); BaseTestClass.contextFactory.SetContextMode(ContextMode.OfflineMode); this.offlineContext = BaseTestClass.contextFactory.GetContext(); }
protected static void EnsureDatabase(FluentModel context) { context.CreateUpdateDatabase(); }
protected static void ClearDatabase(FluentModel context) { context.Users.DeleteAll(); context.Groups.DeleteAll(); }