public void Can_delete_and_add_setting_entries() { var settings = context.Set <Setting>(); settings.Any().ShouldBeFalse(); var entries = GetDefaultSettingEntries(); var migrator = new SettingsMigrator(context); migrator.Migrate(entries); var builder = new SettingsBuilder(); builder.Delete("type1.setting1", "type2.setting1"); migrator.Migrate(builder.Build()); settings.ToList().Count.ShouldEqual(6); builder.Reset(); builder.DeleteGroup("type1"); migrator.Migrate(builder.Build()); settings.ToList().Count.ShouldEqual(3); builder.Reset(); builder.Add("type3.Setting1", true); builder.Add("type3.Setting2", 20); migrator.Migrate(builder.Build()); var db = settings.ToList(); db.Count.ShouldEqual(5); var st = settings.Where(x => x.Name == "type3.Setting2").FirstOrDefault(); st.Value.ShouldEqual("20"); }
public void Can_delete_and_add_setting_entries() { var settings = context.Set<Setting>(); settings.Any().ShouldBeFalse(); var entries = GetDefaultSettingEntries(); var migrator = new SettingsMigrator(context); migrator.Migrate(entries); var builder = new SettingsBuilder(); builder.Delete("type1.setting1", "type2.setting1"); migrator.Migrate(builder.Build()); settings.ToList().Count.ShouldEqual(6); builder.Reset(); builder.DeleteGroup("type1"); migrator.Migrate(builder.Build()); settings.ToList().Count.ShouldEqual(3); builder.Reset(); builder.Add("type3.Setting1", true); builder.Add("type3.Setting2", 20); migrator.Migrate(builder.Build()); var db = settings.ToList(); db.Count.ShouldEqual(5); var st = settings.Where(x => x.Name == "type3.Setting2").FirstOrDefault(); st.Value.ShouldEqual("20"); settings.RemoveRange(db); context.SaveChanges(); }