Inheritance: IMapper
        public IMapper CreateMapper(object data)
        {
            IMapper mapper;

            if (IsXml(data.ToString()))
            {
                mapper = new XmlMapper();
            }
            else if (IsJson(data.ToString()))
            {
                mapper = new JsonMapper();
            }
            else
            {
                if(data.GetType().IsPrimitive)
                {
                    mapper = new PocoMapper();
                }
                else
                {
                    mapper = new StringMapper();
                }
            }
            return mapper;
        }
Ejemplo n.º 2
0
        public void MapXmlWithScalarValue_Expected_PathToScalarValue()
        {
            XmlMapper xmlMapper = new XmlMapper();

            string xml = Given();
            IEnumerable<IPath> paths = xmlMapper.Map(xml);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Company.Motto"));
        }
Ejemplo n.º 3
0
        public void MapXmlWithAttribute_Expected_PathToAttribute()
        {
            XmlMapper xmlMapper = new XmlMapper();

            string xml = Given();
            IEnumerable<IPath> paths = xmlMapper.Map(xml);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Company:Name"));
        }
Ejemplo n.º 4
0
        public void MapXmlWithAInlineRecordset_Expected_PathToItemsInInnerRecordset()
        {
            XmlMapper xmlMapper = new XmlMapper();

            string xml = Given();
            IEnumerable<IPath> paths = xmlMapper.Map(xml);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Company().InlineRecordSet"));
        }
Ejemplo n.º 5
0
        public void MapXmlWithARecordsetAndAttributesOnTheRecordset_Expected_PathToAttributeOfRecordset()
        {
            XmlMapper xmlMapper = new XmlMapper();

            string xml = Given();
            IEnumerable<IPath> paths = xmlMapper.Map(xml);

            Assert.IsTrue(paths.Any(p => p.ActualPath == "Company.Departments:TestAttrib"));
        }