public void SetRulesDataStore_SetsCorrectEntityIdOnSettingsInRule() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); var config = new RemoteConfigConfigData() { type = "settings", id = "someId", value = RCTestUtils.rsListWihtoutMetadata }; dataManager.SetRSDataStore(config); dataManager.SetRulesDataStore(RCTestUtils.rulesList); Assert.That(RuleListsAreEqual(dataStore.rulesList, RCTestUtils.rulesList)); var rulesFromDataStore = dataStore.rulesList; var settingsFromDataStore = dataStore.rsKeyList; for (int i = 0; i < rulesFromDataStore.Count; i++) { for (int j = 0; j < rulesFromDataStore[i].value.Count; i++) { Assert.That(settingsFromDataStore.Contains(rulesFromDataStore[i].value[j])); } } }
public void HasRules_CorrectlyReturnsFalseIfThereAreNoRules() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(dataManager.HasRules() == false); }
public void SetEnvironmentsList_SetsEnvironmentsList() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.SetEnvironmentsList(RCTestUtils.environments); Assert.That(Equals(dataStore.environments, RCTestUtils.environments)); }
public void GetDeletedRulesIDs_ReturnsUpdatedRuleIDList() { var dataStore = RCTestUtils.GetDataStore(); dataStore.deletedRulesIDs = new List <string>(RCTestUtils.deletedRuleIDs); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(Equals(dataManager.GetDeletedRulesIDs(), dataStore.deletedRulesIDs)); }
public void GetCurrentEnvironmentId_ReturnsCurrentEnvironmentId() { var dataStore = RCTestUtils.GetDataStore(); dataStore.currentEnvironmentId = RCTestUtils.currentEnvironmentId; RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(Equals(dataManager.GetCurrentEnvironmentId(), dataStore.currentEnvironmentId)); }
public void GetEnvironments_ReturnsListOfEnvironments() { var dataStore = RCTestUtils.GetDataStore(); dataStore.environments = RCTestUtils.environments; RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(Equals(dataManager.GetEnvironments(), dataStore.environments)); }
public void GetRulesList_ReturnsRulesList() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.SetRulesDataStore(new List <Rule>(RCTestUtils.rulesList)); Assert.That(Equals(dataManager.GetRulesList(), dataStore.rulesList)); }
public void GetRSList_ReturnsRSList() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rsKeyList = new List <RsKvtData>(RCTestUtils.rsListWithMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(Equals(dataManager.GetRSList(), dataStore.rsKeyList)); }
public void HasRules_CorrectlyReturnsTrueIfThereAreRules() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(dataManager.HasRules() == true); }
public void IsSettingInRule_ReturnsTrueWhenSettingIsInRule() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(dataManager.IsSettingInRule(RCTestUtils.ruleOneId, RCTestUtils.stringKeyEntityId)); }
public void IsSettingInRule_ReturnsFalseWhenSettingIsNotInRule() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(!dataManager.IsSettingInRule(RCTestUtils.ruleOneId, "Fake Key")); }
public void SetRulesDataStore_SetsRulesStoreWhenAListIsPassedInWithSettings() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.SetRulesDataStore(RCTestUtils.rulesWithSettingsList); Assert.That(RuleListsAreEqual(dataStore.rulesList, RCTestUtils.rulesWithSettingsList)); }
public void ConfigID_ShouldReturnConfigIDFromDataStore() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Assert.That(string.IsNullOrEmpty(dataManager.configId)); dataStore.configId = "someId"; Assert.That(string.Equals(dataManager.configId, "someId")); }
public void DeleteSetting_DeletesSettingFromListAndDict() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rsKeyList = new List <RsKvtData>(RCTestUtils.rsListWithMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.DeleteSetting(RCTestUtils.rsListWithMetadata[0].metadata.entityId); Assert.That(!dataStore.rsKeyList.Contains(RCTestUtils.rsListWithMetadata[0])); }
public void EnableOrDisableRule_UpdatesEnabledFieldOfRule() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.EnableOrDisableRule(RCTestUtils.ruleOneId, false); Assert.That(dataStore.rulesList.Find(r => r.id == RCTestUtils.ruleOneId).enabled == false); }
public void ValidateRule_ShouldReturnFalseForInvalidRule() { RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); var rule = RCTestUtils.CreateValidRule(); rule.priority = 1400; Assert.That(dataManager.ValidateRule(rule) == false); rule.priority = -1; Assert.That(dataManager.ValidateRule(rule) == false); }
public void RemoveRuleFromDeletedRuleIDs_RemovesRuleFromDeletedRules() { var dataStore = RCTestUtils.GetDataStore(); dataStore.deletedRulesIDs = new List <string>(RCTestUtils.updatedRuleIDs); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.RemoveRuleFromDeletedRuleIDs(RCTestUtils.updatedRuleIDs[0]); Assert.That(dataStore.deletedRulesIDs.Count == 2); Assert.That(!dataStore.deletedRulesIDs.Contains(RCTestUtils.updatedRuleIDs[0])); }
public void AddRule_AddsRuleToRulesListAndAddedRulesIDs() { var dataStore = RCTestUtils.GetDataStore(); var addedRule = RCTestUtils.rulesWithSettingsMetadata[0]; RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.UpdateRule(addedRule); Assert.That(dataStore.rulesList.Contains(addedRule)); Assert.That(dataStore.addedRulesIDs.Contains(addedRule.id)); Assert.That(dataStore.rulesList.Contains(addedRule)); }
public void GetRuleByID_ReturnsRuleWithGivenID() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.SetRulesDataStore(new List <Rule>(RCTestUtils.rulesList)); for (int i = 0; i < dataStore.rulesList.Count; i++) { Assert.That(Equals(dataManager.GetRuleByID(dataStore.rulesList[i].id), dataStore.rulesList[i])); } }
public void AddSettingToRule_ShouldAddRightSettingToRightRule() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); dataStore.rsKeyList = new List <RsKvtData>(RCTestUtils.rsListWithMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.AddSettingToRule(RCTestUtils.ruleOneId, RCTestUtils.stringKeyName); Assert.That(dataStore.rulesList.Find(r => r.id == RCTestUtils.ruleOneId).value.Contains(RCTestUtils.rsListWithMetadata[0])); Assert.That(dataStore.updatedRulesIDs.Contains(RCTestUtils.ruleOneId)); }
public void DeleteSettingFromRule_ShouldRemoveRightSettingsFromRightRule() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); dataStore.rsKeyList = new List <RsKvtData>(RCTestUtils.rsListWithMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.DeleteSettingFromRule(RCTestUtils.ruleOneId, RCTestUtils.intKeyEntityId); Assert.That(!dataStore.rulesList.Find(r => r.id == RCTestUtils.ruleOneId).value.Contains(RCTestUtils.rsListWithMetadata[1])); Assert.That(dataStore.updatedRulesIDs.Contains(RCTestUtils.ruleOneId)); }
public void AddSetting_AddsSettingToListAndDict() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.AddSetting(RCTestUtils.rsListWithMetadata[0]); Assert.That(dataStore.rsKeyList.Contains(RCTestUtils.rsListWithMetadata[0])); var rs = dataStore.rsKeyList.Find(s => s.metadata.entityId == RCTestUtils.rsListWithMetadata[0].metadata.entityId); Assert.That(string.Equals(rs.rs.key, RCTestUtils.rsListWithMetadata[0].rs.key)); Assert.That(string.Equals(rs.rs.type, RCTestUtils.rsListWithMetadata[0].rs.type)); Assert.That(string.Equals(rs.rs.value, RCTestUtils.rsListWithMetadata[0].rs.value)); }
public void DeleteRule_ShouldDeleteNewlyAddedRuleFromRulesListWithoutAddingItToDeletedRuleIDs() { var dataStore = RCTestUtils.GetDataStore(); var deletedRule = RCTestUtils.rulesWithSettingsMetadata[0]; RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.UpdateRule(deletedRule); dataManager.DeleteRule(deletedRule.id); Assert.That(!dataStore.rulesList.Contains(deletedRule)); Assert.That(!dataStore.deletedRulesIDs.Contains(deletedRule.id)); Assert.That(!dataStore.rulesList.Contains(deletedRule)); }
public void ValidateRule_ShouldReturnTrueForAddingDuplicateRuleName() { RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); var rule = RCTestUtils.CreateValidRule(); dataManager.UpdateRule(rule); var ruleDuplicate = RCTestUtils.CreateValidRule(); dataManager.UpdateRule(ruleDuplicate); var rulesList = dataManager.GetRulesList(); Assert.That(rulesList[0].name != rulesList[1].name); }
public void DeleteRule_DeletesRuleFromRulesListAndAddsRuleToDeletedRuleIDs() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); var deletedRule = RCTestUtils.rulesWithSettingsMetadata[0]; RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.DeleteRule(deletedRule.id); Assert.That(!dataStore.rulesList.Contains(deletedRule)); Assert.That(dataStore.deletedRulesIDs.Contains(deletedRule.id)); Assert.That(!dataStore.rulesList.Contains(deletedRule)); }
public void ClearRuleIDs_ClearsAllLists() { var dataStore = RCTestUtils.GetDataStore(); dataStore.updatedRulesIDs = new List <string>(RCTestUtils.updatedRuleIDs); dataStore.addedRulesIDs = new List <string>(RCTestUtils.addedRuleIDs); dataStore.deletedRulesIDs = new List <string>(RCTestUtils.deletedRuleIDs); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); dataManager.ClearRuleIDs(); Assert.That(dataStore.updatedRulesIDs.Count == 0); Assert.That(dataStore.addedRulesIDs.Count == 0); Assert.That(dataStore.deletedRulesIDs.Count == 0); }
public void SetCurrentEnvironment_SetsCurrentEnvironment() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); Environment currentEnvironment = new Environment(); currentEnvironment.name = RCTestUtils.currentEnvironment; currentEnvironment.id = RCTestUtils.currentEnvironmentId; dataManager.SetCurrentEnvironment(currentEnvironment); //Assert.That(Equals(dataStore.currentEnvironment, currentEnvironment.name)); Assert.That(Equals(dataStore.currentEnvironmentId, currentEnvironment.id)); }
public void UpdateSettingForRule_ShouldUpdateSettingOnRightRule() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata); dataStore.rsKeyList = new List <RsKvtData>(RCTestUtils.rsListWithMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); var newVal = "new value"; dataManager.UpdateSettingForRule(RCTestUtils.ruleOneId, new RsKvtData(RCTestUtils.stringKeyEntityId, new RemoteSettingsKeyValueType(RCTestUtils.stringKeyName, "string", newVal))); var setting = dataStore.rulesList.Find(r => r.id == RCTestUtils.ruleOneId).value.Find((obj) => obj.metadata.entityId == RCTestUtils.stringKeyEntityId); Assert.That(string.Equals(setting.rs.value, newVal)); Assert.That(dataStore.updatedRulesIDs.Contains(RCTestUtils.ruleOneId)); }
public void SetRSDataStore_SetsRSDataStoreWhenAListIsPassedIn() { var dataStore = RCTestUtils.GetDataStore(); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); var config = new RemoteConfigConfigData() { type = "settings", id = "someId", value = RCTestUtils.rsListWihtoutMetadata }; dataManager.SetRSDataStore(config); Assert.That(RSListsAreEqual(dataStore.rsKeyList, RCTestUtils.rsListWihtoutMetadata)); }
public void UpdateSetting_UpdatesCorrectSetting() { var dataStore = RCTestUtils.GetDataStore(); dataStore.rsKeyList = new List <RsKvtData>(RCTestUtils.rsListWithMetadata); RemoteConfigDataManager dataManager = new RemoteConfigDataManager(); var newRs = new RsKvtData(RCTestUtils.rsListWithMetadata[0].metadata.entityId, new RemoteSettingsKeyValueType("updated-key", "updated-type", "updated-value")); dataManager.UpdateSetting(RCTestUtils.rsListWithMetadata[0], newRs); Assert.That(!dataStore.rsKeyList.Contains(RCTestUtils.rsListWithMetadata[0])); Assert.That(dataStore.rsKeyList.Contains(newRs)); var rs = dataStore.rsKeyList.Find(s => s.metadata.entityId == newRs.metadata.entityId); Assert.That(string.Equals(rs.rs.key, newRs.rs.key)); Assert.That(string.Equals(rs.rs.type, newRs.rs.type)); Assert.That(string.Equals(rs.rs.value, newRs.rs.value)); }