Exemplo n.º 1
0
        public void EnvironmentAgentRepository_Update()
        {
            var repo = new EnvironmentAgentRepository();

            var key = "D5";
            var environmentAgents = new List <EnvironmentAgent>
            {
                new EnvironmentAgent
                {
                    AgentCountryIsoCode = "FAK",
                    AgentCountry        = "FAKE COUNTRY",
                    AgentStateCode      = "FA",
                    AgentState          = "FAKE STATE",
                    AgentId             = "44440000",
                    AgentSequence       = "00",
                    AgentPassword       = "******",
                    Language            = "en",
                    SendCurrencies      = new List <string> {
                        "USD"
                    }
                }
            };

            repo.UpdateValue(key, environmentAgents);

            var containsKey = repo.ContainsKey(key);
            var value       = repo.GetValue <List <EnvironmentAgent> >(key);

            Assert.IsTrue(containsKey);
            Assert.AreEqual(1, value.Count);
            Assert.AreEqual("FAK", value.FirstOrDefault()?.AgentCountryIsoCode);
        }
Exemplo n.º 2
0
        public void EnvironmentAgentRepository_GetAllValues()
        {
            var repo = new EnvironmentAgentRepository();

            var values = repo.GetAllValues <List <EnvironmentAgentInfoList> >();

            Assert.IsNotNull(values);
            Assert.IsTrue(values.Count > 0);
        }
Exemplo n.º 3
0
        private List <EnvironmentAgent> GetAgentData()
        {
            var testSettings  = TestConfig.TestSettings;
            var acEnvironment = testSettings.AcEnvironment.ToString();
            var repo          = new EnvironmentAgentRepository();

            return(repo.ContainsKey(acEnvironment)
                ? repo.GetValue <List <EnvironmentAgent> >(acEnvironment)
                : new List <EnvironmentAgent>());
        }
Exemplo n.º 4
0
        public void EnvironmentAgentRepository_GetValue()
        {
            var repo = new EnvironmentAgentRepository();

            var key   = "Q5";
            var value = repo.GetValue <List <EnvironmentAgent> >(key);

            Assert.IsNotNull(value);
            Assert.AreEqual(4, value.Count);
        }
Exemplo n.º 5
0
        public void EnvironmentAgentRepository_Search()
        {
            var repo = new EnvironmentAgentRepository();

            var searchTerm = "44869210"; // 40698809 44869210

            var values = repo.Search <List <EnvironmentAgent> >(searchTerm);

            Assert.IsNotNull(values);
            Assert.IsTrue(values.Count > 0);
        }
Exemplo n.º 6
0
        public void EnvironmentAgentRepository_RemoveValue()
        {
            var repo = new EnvironmentAgentRepository();

            var key = "D5";

            repo.RemoveValue(key);

            var containsKey = repo.ContainsKey(key);

            Assert.IsFalse(containsKey);
        }
Exemplo n.º 7
0
        public void Initialize()
        {
            // If the user's config file does not contain a Agent/POS list,
            // then load them from the default EnvironmentAgents.json file.
            if (File.Exists(AgentsDataFilePath) &&
                (!File.Exists(UserConfigFilePath) || !UserSettings.HasAgents))
            {
                var repo = new EnvironmentAgentRepository();
                var environmentAgents = repo.GetAllValues <List <EnvironmentAgentInfoList> >()
                                        .ToDictionary(x => x.Environment, x => x.Agents);

                var settings = UserSettings;
                settings.EnvironmentAgents = environmentAgents;

                SaveSettingsFile(settings);
            }
            else if (File.Exists(UserConfigFilePath))
            {
                // Save Environments.json file with userconfig data. (this usually happens when a new release comes out and they dont want to erase custom agents)
                SaveSettingsFile(UserSettings);
            }
        }