public void UmbracoMapper_MapFromIPublishedContent_MapsNativePropertiesWithStringFormatter() { // Arrange var model = new SimpleViewModel(); var content = new StubPublishedContent(); var mapper = GetMapper(); // Act mapper.Map(content, model, new Dictionary<string, PropertyMapping> { { "Name", new PropertyMapping { StringValueFormatter = x => { return x.ToUpper(); }, } } }); // Assert Assert.AreEqual("TEST CONTENT", model.Name); }
public void UmbracoMapper_MapFromIPublishedContent_MapsNativePropertiesWithMatchingNames() { // Arrange var model = new SimpleViewModel(); var content = new StubPublishedContent(); var mapper = GetMapper(); // Act mapper.Map(content, model); // Assert Assert.AreEqual(1000, model.Id); Assert.AreEqual("Test content", model.Name); }
public SimpleViewModel2bWithAttribute() { Parent = new SimpleViewModel(); }
public void UmbracoMapper_MapFromJson_MapsFromChildProperty() { // Arrange var model = new SimpleViewModel(); var json = GetJsonForSingle4(); var mapper = GetMapper(); // Act mapper.Map(json, model, new Dictionary<string, PropertyMapping> { { "Name", new PropertyMapping { SourceChildProperty = "fullName" } } }); // Assert Assert.AreEqual(1, model.Id); Assert.AreEqual("Test name", model.Name); }
public void UmbracoMapper_MapFromIPublishedContent_DoesNotMapIgnoredNativePropertiesUsingDictionary() { // Arrange var model = new SimpleViewModel(); var content = new StubPublishedContent(); var mapper = GetMapper(); // Act mapper.Map(content, model, new Dictionary<string, PropertyMapping> { { "Name", new PropertyMapping { Ignore = true, } } }); // Assert Assert.AreEqual(1000, model.Id); Assert.IsNull(model.Name); }