示例#1
0
        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]));
                }
            }
        }
示例#2
0
        public void HasRules_CorrectlyReturnsFalseIfThereAreNoRules()
        {
            var dataStore = RCTestUtils.GetDataStore();
            RemoteConfigDataManager dataManager = new RemoteConfigDataManager();

            Assert.That(dataManager.HasRules() == false);
        }
示例#3
0
        public void SetEnvironmentsList_SetsEnvironmentsList()
        {
            var dataStore = RCTestUtils.GetDataStore();
            RemoteConfigDataManager dataManager = new RemoteConfigDataManager();

            dataManager.SetEnvironmentsList(RCTestUtils.environments);

            Assert.That(Equals(dataStore.environments, RCTestUtils.environments));
        }
示例#4
0
        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));
        }
示例#5
0
        public void GetCurrentEnvironmentId_ReturnsCurrentEnvironmentId()
        {
            var dataStore = RCTestUtils.GetDataStore();

            dataStore.currentEnvironmentId = RCTestUtils.currentEnvironmentId;
            RemoteConfigDataManager dataManager = new RemoteConfigDataManager();

            Assert.That(Equals(dataManager.GetCurrentEnvironmentId(), dataStore.currentEnvironmentId));
        }
示例#6
0
        public void GetEnvironments_ReturnsListOfEnvironments()
        {
            var dataStore = RCTestUtils.GetDataStore();

            dataStore.environments = RCTestUtils.environments;
            RemoteConfigDataManager dataManager = new RemoteConfigDataManager();

            Assert.That(Equals(dataManager.GetEnvironments(), dataStore.environments));
        }
示例#7
0
        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));
        }
示例#8
0
        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));
        }
示例#9
0
        public void HasRules_CorrectlyReturnsTrueIfThereAreRules()
        {
            var dataStore = RCTestUtils.GetDataStore();

            dataStore.rulesList = new List <RuleWithSettingsMetadata>(RCTestUtils.rulesWithSettingsMetadata);
            RemoteConfigDataManager dataManager = new RemoteConfigDataManager();

            Assert.That(dataManager.HasRules() == true);
        }
示例#10
0
        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));
        }
示例#11
0
        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"));
        }
示例#12
0
        public void SetRulesDataStore_SetsRulesStoreWhenAListIsPassedInWithSettings()
        {
            var dataStore = RCTestUtils.GetDataStore();
            RemoteConfigDataManager dataManager = new RemoteConfigDataManager();

            dataManager.SetRulesDataStore(RCTestUtils.rulesWithSettingsList);

            Assert.That(RuleListsAreEqual(dataStore.rulesList, RCTestUtils.rulesWithSettingsList));
        }
示例#13
0
        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"));
        }
示例#14
0
        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]));
        }
示例#15
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);
        }
示例#16
0
        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);
        }
示例#17
0
        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]));
        }
示例#18
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));
        }
示例#19
0
        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]));
            }
        }
示例#20
0
        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));
        }
示例#21
0
        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));
        }
示例#22
0
        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));
        }
示例#23
0
        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));
        }
示例#24
0
        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);
        }
示例#25
0
        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));
        }
示例#26
0
        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);
        }
示例#27
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));
        }
示例#28
0
        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));
        }
示例#29
0
        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));
        }
示例#30
0
        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));
        }