Copied to clipboard

Flag this post as spam?

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


  • Daniel Mckibbin 14 posts 106 karma points
    Jun 04, 2018 @ 11:20
    Daniel Mckibbin
    0

    Accessing Custom Properties from IMember (IContentBase) for Unit Testing

    Currently I have got a mock IMember setup where I can access it's standard properties that are directly accessible (email, username, name etc) but any custom properties that are set in .SetValue from IContentBase I cannot access or set for that matter.

    [TestFixture]
    public class InactiveMemberCheckTest
    {
        private UmbracoSupport support = new UmbracoSupport();
        private Mock<IMember> inactiveMemberEmailed;
    
        [SetUp]
        public void Setup()
        {
            support.SetupUmbraco();
            this.inactiveMemberEmailed = new Mock<IMember>();
            inactiveMemberEmailed.SetupAllProperties();
    
            inactiveMemberEmailed.Object.LastLoginDate = DateTime.Today.AddMonths(-12);
            inactiveMemberEmailed.Object.Name = "inactiveMemberEmailed";
            inactiveMemberEmailed.Object.Email = "[email protected]";
            inactiveMemberEmailed.Object.SetValue("contactId", 1);
            inactiveMemberEmailed.Object.SetValue("inactiveCheckEmailed", true);
    
        }
    }
    

    The contactId and inactiveCheckEmailed both are not being set. As mentioned previously all the other values are being set fine, it's just those 2 custom properties.

    Could anybody point me in the right direction for this please? Thanks.

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Jun 06, 2018 @ 13:09
    Søren Gregersen
    0

    There is no implementation of SetValue, so it is just a method call.

    Have a look at the quickstart here : https://github.com/Moq/moq4/wiki/Quickstart

Please Sign in or register to post replies

Write your reply to:

Draft