Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • nickornotto 403 posts 907 karma points
    Jun 11, 2018 @ 08:44
    nickornotto
    0

    Issue setting mocked property value of IPublishedContent mocked object during unit testing

    I'm trying out UmbracoSupport: https://github.com/lars-erik/umbraco-unit-testing-samples/blob/master/Umb.Testing.Tests/SampleUmbracoTests/StubbingAuthorAnd_Date.cs

    However when I'm executing:

            var prop = new Mock<IPublishedProperty>();
            prop.Setup(p => p.Value).Returns(value);
            Mock.Get(content).Setup(c => c.GetProperty(alias, false)).Returns(prop.Object);
    

    The property object does not set properly. The value gets set up but the PropertyTypeAlias comes null, DataValue is null and HasValue is false as a result.

    What could I have missed?

Please Sign in or register to post replies

Write your reply to:

Draft