public void Convert_ArrayDataTypeAsEnumerableXmlRpcValue_ReturnsCorrectValue() { var converter = new XmlRpcValueToDataConverter(); var xmlRpcValue = new ArrayValue(new[] { new StringValue("1234"), new StringValue("abcd") }); var value = converter.Convert(xmlRpcValue, typeof(IEnumerable <XmlRpcValue>)) as IEnumerable <XmlRpcValue>; Assert.NotNull(value); Assert.Equal(2, value.Count()); var firstValue = value.First() as StringValue; var secondValue = value.Last() as StringValue; Assert.NotNull(firstValue); Assert.NotNull(secondValue); Assert.Equal("1234", firstValue.Value); Assert.Equal("abcd", secondValue.Value); }
public void Convert_ArrayDataTypeAsArrayXmlRpcValue_ReturnsCorrectValue() { var converter = new XmlRpcValueToDataConverter(); var xmlRpcValue = new ArrayValue(new[] { new StringValue("1234"), new StringValue("abcd") }); var value = converter.Convert(xmlRpcValue, typeof(XmlRpcValue[])) as XmlRpcValue[]; Assert.NotNull(value); Assert.Equal(2, value.Length); var firstValue = value[0] as StringValue; var secondValue = value[1] as StringValue; Assert.NotNull(firstValue); Assert.NotNull(secondValue); Assert.Equal("1234", firstValue.Value); Assert.Equal("abcd", secondValue.Value); }
public void Convert_DictionaryWithString_ReturnsCorrectValue() { var converter = new XmlRpcValueToDataConverter(); var xmlRpcValue = new StructValue(new Dictionary <string, XmlRpcValue> { { "TestProp1", new StringValue("1234") }, { "TestProp2", new StringValue("abcd") } }); var value = converter.Convert(xmlRpcValue, typeof(Dictionary <string, string>)) as IDictionary <string, string>; Assert.NotNull(value); Assert.Equal(2, value.Keys.Count); var firstValue = value["TestProp1"]; var secondValue = value["TestProp2"]; Assert.Equal("1234", firstValue); Assert.Equal("abcd", secondValue); }