コード例 #1
0
        public void ObjectMappingTest(string input, Type expectedType)
        {
            XmlDocument xmlNode = new XmlDocument();

            xmlNode.LoadXml(input);

            IConfigurationReader configurationParser = Substitute.For <IConfigurationReader>();

            configurationParser.ReadObject(expectedType, xmlNode).Returns(new TestClass {
                A = "test"
            });

            IMappingStrategy mappingStrategy = new ObjectMappingStrategy();
            var actual = mappingStrategy.Map(xmlNode, expectedType, configurationParser);

            Assert.AreEqual(expectedType, actual.GetType());
        }
コード例 #2
0
        /// <summary>
        /// Convert xml node into the object.
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="collectionType">Object's type.</param>
        /// <param name="configurationReader">The IConfigurationReader instance.</param>
        /// <returns>The object.</returns>
        public object Map(XmlNode node, Type collectionType, IConfigurationReader configurationReader)
        {
            var value = configurationReader.ReadObject(collectionType, node);

            return(value);
        }