public void SaveConfiguration_ShouldSaveCorrectComplexType()
        {
            var testString = "test_string_to_save";
            var config     = new ComplexTestConfiguration()
            {
                TestConfiguration = new TestConfiguration()
                {
                    TestString   = testString,
                    TestChar     = 'T',
                    TestInt      = 10,
                    TestUint     = 100u,
                    TestUintList = new List <uint>()
                    {
                        1, 2, 3, 4
                    }
                }
            };

            _iniWrapper.SaveConfiguration(config);

            _iniParser.Received(1).Write(nameof(TestConfiguration), nameof(TestConfiguration.TestString), testString);
            _iniParser.Received(1).Write(nameof(TestConfiguration), nameof(TestConfiguration.TestChar), config.TestConfiguration.TestChar.ToString());
            _iniParser.Received(1).Write(nameof(TestConfiguration), nameof(TestConfiguration.TestInt), config.TestConfiguration.TestInt.ToString());
            _iniParser.Received(1).Write(nameof(TestConfiguration), nameof(TestConfiguration.TestUint), config.TestConfiguration.TestUint.ToString());
            _iniParser.Received(1).Write(nameof(TestConfiguration), nameof(TestConfiguration.TestUintList), "1,2,3,4");
        }
Esempio n. 2
0
        public void LoadConfiguration_ShouldLoadCorrectComplexType()
        {
            var testString = "test_string_to_save";
            var config     = new ComplexTestConfiguration()
            {
                TestConfiguration = new TestConfiguration()
                {
                    TestString   = testString,
                    TestChar     = 'T',
                    TestInt      = 10,
                    TestUint     = 100u,
                    TestUintList = new List <uint>()
                    {
                        1, 2, 3, 4
                    }
                }
            };

            _iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestString)).Returns(testString);
            _iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestChar)).Returns(config.TestConfiguration.TestChar.ToString());
            _iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestInt)).Returns(config.TestConfiguration.TestInt.ToString());
            _iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestUint)).Returns(config.TestConfiguration.TestUint.ToString());
            _iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestUintList)).Returns("1,2,3,4");
            _iniParser.Read(nameof(TestConfiguration), nameof(TestConfiguration.TestUintIList)).Returns("1,2,3,4");

            var result = _iniWrapper.LoadConfiguration <ComplexTestConfiguration>();


            result.TestConfiguration.TestChar.Should().Be(config.TestConfiguration.TestChar);
            result.TestConfiguration.TestStringList.Should().BeEquivalentTo(config.TestConfiguration.TestStringList);
            result.TestConfiguration.TestEnum.Should().Be(config.TestConfiguration.TestEnum);
            result.TestConfiguration.TestEnumList.Should().BeEquivalentTo(config.TestConfiguration.TestEnumList);
            result.TestConfiguration.TestInt.Should().Be(config.TestConfiguration.TestInt);
            result.TestConfiguration.TestUint.Should().Be(config.TestConfiguration.TestUint);
            result.TestConfiguration.TestUintList.Should().BeEquivalentTo(config.TestConfiguration.TestUintList);
            result.TestConfiguration.TestUintIList.Should().BeEquivalentTo(config.TestConfiguration.TestUintList);
            result.TestConfiguration.TestString.Should().Be(config.TestConfiguration.TestString);
            result.TestConfiguration.TestIntList.Should().BeEquivalentTo(config.TestConfiguration.TestIntList);
        }