コード例 #1
0
        public void Map_Simple_SuccessMap()
        {
            var value        = "some value";
            var configMapper = new ConfigMapper <ClassSimple>();

            var path = new List <string>
            {
                "ClassName",
                "PropStringPublic",
            };

            configMapper.Map(path, value);

            var expected = new ClassSimple()
            {
                PropStringPublic = value
            };

            var result = configMapper.GetResultObject();

            result.Should().BeEquivalentTo(expected);
        }
コード例 #2
0
        public void Map_Nested_SuccessMap()
        {
            var valueString = "some string value";
            var valueInt    = 10;
            var valueDouble = 1.4;
            var valueLong   = -15;
            var valueBool   = true;

            var configMapper = new ConfigMapper <ClassDoubleNested>();

            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropInt"
            }, valueInt);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropString"
            }, valueString);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropClassNested1", "PropDouble"
            }, valueDouble);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropClassNested1", "PropLong"
            }, valueLong);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropClassNested1", "PropClass", "PropBool"
            }, valueBool);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropClassNested2", "PropDouble"
            }, valueDouble);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropClassNested2", "PropLong"
            }, valueLong);
            configMapper.Map(new List <string> {
                "ClassDoubleNested", "PropClassNested2", "PropClass", "PropBool"
            }, valueBool);

            var expected = new ClassDoubleNested()
            {
                PropInt          = valueInt,
                PropString       = valueString,
                PropClassNested1 = new ClassNested()
                {
                    PropDouble = valueDouble,
                    PropLong   = valueLong,
                    PropClass  = new Class()
                    {
                        PropBool = valueBool
                    }
                },
                PropClassNested2 = new ClassNested()
                {
                    PropDouble = valueDouble,
                    PropLong   = valueLong,
                    PropClass  = new Class()
                    {
                        PropBool = valueBool
                    }
                }
            };

            var result = configMapper.GetResultObject();

            result.Should().BeEquivalentTo(expected);
        }