public void UmbracoMapper_MapFromIPublishedContent_AutomapsRelatedIPublishedContent()
        {
            // Using a shim of umbraco.dll
            using (ShimsContext.Create())
            {
                // Arrange
                var model = new SimpleViewModel3WithAttribute();
                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 "subHeading":
                                return "This is the sub-heading";
                            case "bodyText":
                                return "This is the body text";
                            case "subModelValue":
                                return new StubPublishedContent();
                            case "subModelValues":
                                return new List<StubPublishedContent> { new StubPublishedContent(), new StubPublishedContent() };
                            default:
                                return string.Empty;
                        }
                    };

                // Act
                mapper.Map(content, model);

                // Assert
                Assert.AreEqual("This is the body text", model.BodyText);
                Assert.AreEqual("This is the sub-heading", model.SubModelValue.SubHeading);
                Assert.AreEqual(2, model.SubModelValues.Count());
                Assert.AreEqual("This is the sub-heading", model.SubModelValues.First().SubHeading);
            }
        }
        public void UmbracoMapper_MapFromIPublishedContent_MapsWithStringDefaultValueUsingAttribute()
        {
            // Using a shim of umbraco.dll
            using (ShimsContext.Create())
            {
                // Arrange
                var model = new SimpleViewModel3WithAttribute();
                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":
                                return null;
                            case "bodyText2":
                                return string.Empty;
                            default:
                                return string.Empty;
                        }
                    };

                // Act
                mapper.Map(content, model);

                // Assert
                Assert.AreEqual("Default body text", model.BodyText);
                Assert.AreEqual("Default body text 2", model.BodyText2);
            }
        }
        public void UmbracoMapper_MapFromIPublishedContent_MapsWithIntegerDefaultValueUsingAttribute()
        {
            // Using a shim of umbraco.dll
            using (ShimsContext.Create())
            {
                // Arrange
                var model = new SimpleViewModel3WithAttribute();
                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) =>
                    {
                        return string.Empty;
                    };

                // Act
                mapper.Map(content, model);

                // Assert
                Assert.AreEqual(99, model.NonMapped);
            }
        }