public void AddSettingTest() { const string originalSetting = "Original Setting"; const string newSetting = "New Setting"; const int version = 1; ISettingProvider provider = new SingleVersionSettingProvider(); var setting = provider.GetLatestSetting(); Assert.IsNull(setting); provider.AddSetting(originalSetting); setting = provider.GetLatestSetting(); Assert.AreEqual(originalSetting, setting); setting = provider[version]; Assert.AreEqual(originalSetting, setting); provider.AddSetting(newSetting); setting = provider.GetLatestSetting(); Assert.AreEqual(newSetting, setting); setting = provider[version + 1]; Assert.AreEqual(newSetting, setting); }
public void RemoveSettingTest() { const string insertedSetting = "Test Setting"; const int version = 1; ISettingProvider provider = new SingleVersionSettingProvider(); Assert.IsFalse(provider.RemoveSetting(version)); provider.AddSetting(insertedSetting); Assert.IsFalse(provider.RemoveSetting(version + 1)); Assert.IsTrue(provider.RemoveSetting(version)); Assert.IsNull(provider.GetLatestSetting()); }
public void UpdateSettingWithWrongVersionTest() { const string originalSetting = "Original Setting"; const string newSetting = "New Setting"; const int version = 1; ISettingProvider provider = new SingleVersionSettingProvider(); provider.UpdateSetting(version, newSetting); Assert.IsNull(provider.GetLatestSetting()); provider.AddSetting(originalSetting); Assert.AreEqual(originalSetting, provider[version]); provider.UpdateSetting(version + 1, newSetting); Assert.AreEqual(originalSetting, provider[version]); Assert.AreEqual(originalSetting, provider.GetLatestSetting()); }