Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / JustMock > General Discussions > How to Mock Poco Property Behaviour from Interface

Not answered How to Mock Poco Property Behaviour from Interface

Feed from this thread
  • Andre avatar

    Posted on Jun 16, 2011 (permalink)

    I dug through the forums and found this post
    http://www.telerik.com/community/forums/justmock/general-discussions/how-to-set-up-property-assignment.aspx

    I have the Free Edition, Telerik.JustMock.dll File Version 2011.1.315.0
    The promise of a build available next week in August 2010, doesn't prove to work with Behavior.CallOriginal.  (an empty Constructor works though).

    Here is a sample of my TestMethod
    public interface ISamplePoco
    {
      string Name { get; set; }
    }
     
    [TestMethod]
    public void GenerateMockWithPocoPropertyBehaviour()
    {
      // arrange
      var target = Mock.Create<ISamplePoco>(Behavior.CallOriginal);   
      // act
      target.Name = "Dude";
      target.Name += "s";   
      // assert
      Assert.AreEqual("Dudes", target.Name);
    }

    I tried the above code with no parameters for the constructor, all 3 behaviour enums for the Constructor, but nothing works.
    I tried to do some code where I stored the name parameter as a local variable to the test and implement my own logic, but I can't seem to get the actual value in ArrangeSet.  I tried to do something like:

    string name = string.Empty;
    Mock.Arrange(() => target.Name).Returns(name);
    Mock.ArrangeSet((string val) => { name = val; }).IgnoreArguments();

    But there is nothing like that. Is there another solution?
    Thanks

    Reply

  • Andre avatar

    Posted on Jun 21, 2011 (permalink)

    I would like a response from someone on this.  I think waiting 5 days is sufficient time to wait for a response.

    Actually responding would be most appreciated.
    Here is some options for you guys to respond to me with
    • it should work, we'll tell you what you are doing wrong.
    • it works on my machine (i have code you can clearly copy and paste into visual studio).
    • what you are doing is wrong and against windows standards, don't do it.
    • we are looking into putting this feature in a future version, you'll have to wait.

    Reply

  • Ricky Ricky admin's avatar

    Posted on Jun 22, 2011 (permalink)

    Hi Andre,

    Sorry for the late reply. I am actually working on this currently and in a day or two i will be able to send you an internal build. In the meantime, you could open up a support ticket so that we can send you the build there (since we can't send internal build in public forum).

    Ideally, the following will work as expected when the fix is done.


    // arrange
    var target = Mock.Create<ISamplePoco>();
     
    // act
    target.Name = "Dude";
    target.Name += "s";
     
    // assert
    Assert.AreEqual("Dudes", target.Name);

    Here, i re-wrote the test removing the Behavior.CallOriginal since there is no base to call for in interface.

    Sorry for any inconvenience.


    Finally, here is the issue to follow:
    http://www.telerik.com/support/pits.aspx#/public/justmock/6598


    KInd Regardds,
    Mehfuz
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Jeff avatar

    Posted on Aug 17, 2011 (permalink)

    I saw that this issue was resolved in the public issue tracker, but is not scheduled until the next release in the fall.  Is an internal build available to download so that I can test out this functionality?

    Reply

  • Andre avatar

    Posted on Aug 17, 2011 (permalink)

    The issue is fixed.  It passes my test assuming the version written below.
    The current downloadable release (2011.2.713.2) updated on July 13th fixed this issue.

    I believe my original issue was with the 2011 Q1 release? but the Q2 release in July fixed it.
    Hope that helps
    -Andre

    Reply

  • Jeff avatar

    Posted on Aug 17, 2011 (permalink)

    Andre, thanks for the info!  I didn't realize that the fix was already incorporated.  I'll have to try it out.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / JustMock > General Discussions > How to Mock Poco Property Behaviour from Interface