Example #1
0
        public void Convert_TestData_IsMappedCorrectToXmlRpcStruct()
        {
            const int    intData    = 1234;
            const string stringData = "TestData";

            var testData = new StructTestData
            {
                IntValue    = intData,
                StringValue = stringData
            };

            var converter = new DataToXmlRpcValueConverter();

            var convertedValue = converter.Convert(testData);

            Assert.IsType <StructValue>(convertedValue);

            var xmlStructValue = (StructValue)convertedValue;

            Assert.Equal(2, xmlStructValue.Value.Count);

            var intValue    = xmlStructValue.Value["IntTest"] as IntegerValue;
            var stringValue = xmlStructValue.Value["StringTest"] as StringValue;

            Assert.NotNull(intValue);
            Assert.NotNull(stringValue);

            Assert.Equal(intData, intValue.Value);
            Assert.Equal(stringData, stringValue.Value);
        }
        public void Convert_TestDataWithSubProperty_IsMappedCorrectToXmlRpcStruct()
        {
            const int    intData    = 1234;
            const string stringData = "TestData";

            var testData = new StructTestData
            {
                IntValue    = intData,
                StringValue = stringData,
                SubData     = new SubTestData
                {
                    Id   = 5678,
                    Name = "Its"
                }
            };

            var converter = new DataToXmlRpcValueConverter();

            var convertedValue = converter.Convert(testData);

            Assert.IsType <StructValue>(convertedValue);

            var xmlStructValue = (StructValue)convertedValue;

            Assert.Equal(3, xmlStructValue.Value.Count);

            var intValue     = xmlStructValue.Value["IntTest"] as IntegerValue;
            var stringValue  = xmlStructValue.Value["StringTest"] as StringValue;
            var subDataValue = xmlStructValue.Value["SubData"] as StructValue;

            Assert.NotNull(intValue);
            Assert.NotNull(stringValue);
            Assert.NotNull(subDataValue);

            Assert.Equal(intData, intValue.Value);
            Assert.Equal(stringData, stringValue.Value);
            Assert.Equal(2, subDataValue.Value.Count);

            var idValue   = subDataValue.Value["Id"] as IntegerValue;
            var nameValue = subDataValue.Value["Name"] as StringValue;

            Assert.NotNull(idValue);
            Assert.NotNull(nameValue);
            Assert.Equal(5678, idValue.Value);
            Assert.Equal("Its", nameValue.Value);
        }