public void Convert_TestDataWithArrayProperty_IsMappedCorrectToXmlRpcStruct()
        {
            const int    intData    = 1234;
            const string stringData = "TestData";

            var testData = new StructTestDataWithArray
            {
                IntValue    = intData,
                StringValue = stringData,
                SubItems    = new[]
                {
                    new SubTestData
                    {
                        Id   = 2345,
                        Name = "Item1"
                    },
                    new SubTestData
                    {
                        Id   = 3456,
                        Name = "Item2"
                    }
                }
            };

            var converter = new DataToXmlRpcValueConverter();

            var convertedValue = converter.Convert(testData);

            Assert.IsType <StructValue>(convertedValue);

            var xmlStructValue = (StructValue)convertedValue;

            CheckTestData(xmlStructValue, intData, stringData, 2345, "Item1", 3456, "Item2");
        }
        public void Convert_TestDataToXmlRpcAndBack_IsMappedCorrectToObject()
        {
            const int    intData    = 1234;
            const string stringData = "TestData";

            var testData = new StructTestDataWithArray
            {
                IntValue    = intData,
                StringValue = stringData,
                SubItems    = new[]
                {
                    new SubTestData
                    {
                        Id   = 2345,
                        Name = "Item1"
                    },
                    new SubTestData
                    {
                        Id   = 3456,
                        Name = "Item2"
                    }
                }
            };

            var objectToXmlRpcConverter = new DataToXmlRpcValueConverter();

            var xmlRpcToObjectConverter = new XmlRpcValueToDataConverter();

            var xmlRpcValue = objectToXmlRpcConverter.Convert(testData);

            var convertedTestData = xmlRpcToObjectConverter.Convert <StructTestDataWithArray>(xmlRpcValue);

            Assert.Equal(testData.IntValue, convertedTestData.IntValue);
            Assert.Equal(testData.StringValue, convertedTestData.StringValue);
            Assert.Null(convertedTestData.SubData);
            Assert.Equal(testData.SubItems.Length, convertedTestData.SubItems.Length);
            for (var i = 0; i < testData.SubItems.Length; i++)
            {
                Assert.Equal(testData.SubItems[i].Id, convertedTestData.SubItems[i].Id);
                Assert.Equal(testData.SubItems[i].Name, convertedTestData.SubItems[i].Name);
            }
        }
        public void Convert_TestDataArray_IsMappedCorrectToXmlRpcArray()
        {
            const int    intData    = 1234;
            const string stringData = "TestData";

            const int    intData2    = 2468;
            const string stringData2 = "TestData";

            var testData0 = new StructTestDataWithArray
            {
                IntValue    = intData,
                StringValue = stringData,
                SubItems    = new[]
                {
                    new SubTestData
                    {
                        Id   = 2345,
                        Name = "Item1"
                    },
                    new SubTestData
                    {
                        Id   = 3456,
                        Name = "Item2"
                    }
                }
            };

            var testData1 = new StructTestDataWithArray
            {
                IntValue    = intData2,
                StringValue = stringData2,
                SubItems    = new[]
                {
                    new SubTestData
                    {
                        Id   = 45,
                        Name = "Item21"
                    },
                    new SubTestData
                    {
                        Id   = 78,
                        Name = "Item22"
                    }
                }
            };

            var testData = new[] { testData0, testData1 }.ToArray();

            var converter = new DataToXmlRpcValueConverter();

            var convertedValue = converter.Convert(testData);

            Assert.IsType <ArrayValue>(convertedValue);

            var arrayValue = (ArrayValue)convertedValue;

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

            var firstValue = arrayValue.Value.First();
            var lastValue  = arrayValue.Value.Last();

            Assert.IsType <StructValue>(firstValue);
            Assert.IsType <StructValue>(lastValue);

            CheckTestData((StructValue)firstValue, intData, stringData, 2345, "Item1", 3456, "Item2");

            CheckTestData((StructValue)lastValue, intData2, stringData2, 45, "Item21", 78, "Item22");
        }