Copied to clipboard

Flag this post as spam?

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


  • nickornotto 317 posts 679 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?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies