public void MapsComplexTypeArray() { var sut = new ContentData { Html = @"<Sample> <Item> <Value>123</Value> </Item> <Item> <Value>234</Value> </Item> <Item> <Value>345</Value> </Item> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <ComplexEnumerableParent>(); Assert.AreEqual(result.Items.First().Value, 123); Assert.AreEqual(result.Items.Skip(1).First().Value, 234); Assert.AreEqual(result.Items.Skip(2).First().Value, 345); }
public void LoadTest() { Mapper.RegisterType <EnumerableResult>(); var sut = new ContentData { Html = @"<Sample> <Value>123</Value> <Value>234</Value> <Value>345</Value> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var start = DateTime.Now; for (var i = 0; i < 30000; i++) { var result = sut.AsContentType <EnumerableResult>(); } var end = DateTime.Now; Console.WriteLine(end - start); }
public void MapsDate() { var sut = new ContentData() { DateCreated = DateTime.Now }; var result = sut.AsContentType <DateResult>(); Assert.AreEqual(result.CreatedDate, sut.DateCreated); }
public void MapsInteger() { var sut = new ContentData { Html = @"<Sample> <Value id=""123"">text</Value> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <IntegerResult>(); Assert.AreEqual(result.Value, 123); }
public void MapsString() { var sut = new ContentData { Html = @"<Sample> <Value>123</Value> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <StringResult>(); Assert.AreEqual(result.Value, "123"); }
public void MapsEnum() { var sut = new ContentData { Html = @"<Sample> <Value>1</Value> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <EnumResult>(); Assert.AreEqual(result.Value, EnumOptions.Second); }
public void LoadTest() { Mapper.RegisterType <DateResult>(); var sut = new ContentData() { DateCreated = DateTime.Now }; var start = DateTime.Now; for (var i = 0; i < 30000; i++) { var result = sut.AsContentType <DateResult>(); } var end = DateTime.Now; Console.WriteLine(end - start); }
public void MapsString() { var sut = new ContentData() { MetaData = new ContentMetaData[] { new ContentMetaData() { Name = "Value", Text = "123" } } }; var result = sut.AsContentType<StringResult>(); Assert.AreEqual(result.Value, "123"); }
public void MapsComplexType() { var sut = new ContentData { Html = @"<Sample> <Item> <Value>123</Value> </Item> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <ComplexParent>(); Assert.AreEqual(result.Item.Value, 123); }
public void MapsBaseAndDerivedClasses() { var sut = new ContentData { Html = @"<Sample> <Value>123</Value> <Value2>234</Value2> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <DerivedIntegerResult>(); Assert.AreEqual(result.Value, 123); Assert.AreEqual(result.Value2, 234); }
public void MapsDateTime() { var now = DateTime.Parse(DateTime.Now.ToString()); var html = @"<Sample> <Value>{0}</Value> </Sample>"; var sut = new ContentData { Html = string.Format(html, now), XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <DateTimeResult>(); Assert.AreEqual(result.Value, now); }
public void MapsEnumerable() { var sut = new ContentData() { MetaData = new ContentMetaData[] { new ContentMetaData() { Name = "Values", Text = "123;234", Separator = ";", AllowMultiple = true } } }; var result = sut.AsContentType<EnumerableResult>(); Assert.AreEqual(result.Values.First(), "123"); Assert.AreEqual(result.Values.Skip(1).First(), "234"); }
public void MapsPrimitiveArray() { var sut = new ContentData { Html = @"<Sample> <Value>123</Value> <Value>234</Value> <Value>345</Value> </Sample>", XmlConfiguration = new XmlConfigData() { Id = 1, } }; var result = sut.AsContentType <EnumerableResult>(); Assert.AreEqual(result.Value.First(), 123); Assert.AreEqual(result.Value.Skip(1).First(), 234); Assert.AreEqual(result.Value.Skip(2).First(), 345); }