public void Ctor_UseCommandParameter_PrimaryConfigTakesPriorityCaseInsensitive_UsedConfigFileIsFalse()
        {
            Dictionary <string, string> input = new Dictionary <string, string>
            {
                { Key1.ToUpper(), StringValue },
                { Key2, LongAsString },
            };

            CommandParameters sessionParameters = new CommandParameters(input, string.Empty);

            Dictionary <string, string> primaryConfig = new Dictionary <string, string>
            {
                { Key1.ToLower(), BoolAsString },   // This should take priority
                { Key3, StringValue }
            };

            CommandParameters parameters = new CommandParameters(primaryConfig, sessionParameters);

            Assert.IsFalse(parameters.UsedConfigFile);
            Assert.AreEqual(3, parameters.ConfigCopy.Count);
            Assert.IsTrue(parameters.TryGetString(Key1, out string value));
            Assert.AreEqual(BoolAsString, value);
            Assert.IsTrue(parameters.TryGetString(Key2, out value));
            Assert.AreEqual(LongAsString, value);
            Assert.IsTrue(parameters.TryGetString(Key3, out value));
            Assert.AreEqual(StringValue, value);
        }
        public void Ctor_ValuesInDictionary_HasCaseInsensitiveMatchingProperties_UsedConfigFileIsFalse()
        {
            Dictionary <string, string> input = new Dictionary <string, string>
            {
                { Key1, StringValue },
                { Key2, LongAsString },
                { Key3, BoolAsString }
            };

            CommandParameters parameters = new CommandParameters(input, string.Empty);

            Assert.IsFalse(parameters.UsedConfigFile);
            Assert.AreEqual(input.Count, parameters.ConfigCopy.Count);
            Assert.IsTrue(parameters.TryGetString(Key1.ToUpper(), out string value));
            Assert.AreEqual(StringValue, value);
            Assert.IsTrue(parameters.TryGetString(Key2.ToLower(), out value));
            Assert.AreEqual(LongAsString, value);
            Assert.IsTrue(parameters.TryGetString(Key3, out value));
            Assert.AreEqual(BoolAsString, value);
        }
        public void Ctor_ValuesInValidConfigFile_HasMatchingProperties_UsedConfigFileIsTrue()
        {
            using (ShimsContext.Create())
            {
                ShimFile.ExistsString      = (_) => true;
                ShimFile.ReadAllTextString = (_) => JsonSettingKey1ToStringValue;

                CommandParameters parameters = new CommandParameters(EmptyInput, FakeConfigFile);
                Assert.IsTrue(parameters.UsedConfigFile);
                Assert.AreEqual(1, parameters.ConfigCopy.Count);
                Assert.IsTrue(parameters.TryGetString(Key1, out string value));
                Assert.AreEqual(StringValue, value);
            }
        }
        public void Ctor_ValuesInValidConfigFile_OverrideInDictionary_PropertyMatchesDictionary()
        {
            using (ShimsContext.Create())
            {
                ShimFile.ExistsString      = (_) => true;
                ShimFile.ReadAllTextString = (_) => JsonSettingKey1ToStringValue;

                Dictionary <string, string> input = new Dictionary <string, string>
                {
                    { Key1, BoolAsString }
                };
                CommandParameters parameters = new CommandParameters(input, FakeConfigFile);
                Assert.AreEqual(1, parameters.ConfigCopy.Count);
                Assert.IsTrue(parameters.TryGetString(Key1, out string value));
                Assert.AreEqual(BoolAsString, value);
            }
        }
        public void TryGetString_NoMatchingKey_ReturnsFalse()
        {
            CommandParameters parameters = new CommandParameters(EmptyInput, string.Empty);

            Assert.IsFalse(parameters.TryGetString(Key1, out string value));
        }