public void UmbracoMapper_MapFromIPublishedContent_MapsCustomPropertiesWithDifferentNamesUsingAttributeAndRecursiveProperty() { // Using a shim of umbraco.dll using (ShimsContext.Create()) { // Arrange var model = new SimpleViewModel4bWithAttribute(); var mapper = GetMapper(); var content = new StubPublishedContent(); // - shim GetPropertyValue (an extension method on IPublishedContent so can't be mocked) Umbraco.Web.Fakes.ShimPublishedContentExtensions.GetPropertyValueIPublishedContentStringBoolean = (doc, alias, recursive) => { switch (alias) { case "bodyText": if (recursive) { return "This is the body text"; } return string.Empty; default: return string.Empty; } }; // Act mapper.Map(content, model); // Assert Assert.AreEqual(1000, model.Id); Assert.AreEqual("Test content", model.Name); Assert.AreEqual("This is the body text", model.BodyCopy); } }
public void UmbracoMapper_MapFromIPublishedContent_MapsNullToNullableDateTimeWithNoValue() { // Using a shim of umbraco.dll using (ShimsContext.Create()) { // Arrange var model = new SimpleViewModel4bWithAttribute(); var mapper = GetMapper(); var content = new StubPublishedContent(); // - shim GetPropertyValue (an extension method on IPublishedContent so can't be mocked) Umbraco.Web.Fakes.ShimPublishedContentExtensions.GetPropertyValueIPublishedContentStringBoolean = (doc, alias, recursive) => { switch (alias) { case "dateTime": return "1/1/0001 12:00:00 AM"; default: return string.Empty; } }; // Act mapper.Map(content, model); // Assert Assert.IsFalse(model.DateTime.HasValue); } }