Occurs.Exactly() possible with AssertSet() ?

2 posts, 0 answers
  1. Jeroen Speldekamp
    Jeroen Speldekamp avatar
    30 posts
    Member since:
    Mar 2005

    Posted 14 Oct 2010 Link to this post


    I got a question if it is possible to ask how many times a mock property has been set. What is got till now is this witch works but it aint the correct way to use I guess.

    int nameCount = 0;
    Mock.ArrangeSet(() => _mock.Name = Arg.AnyString).DoInstead(() => nameCount += 1).MustBeCalled();

    I thought that maybe the right way to use it is something like this

    Mock.AssertSet(() => { _mock.Name = Arg.AnyString; }, Occurs.Exactly(2));

    Because the Assert() method can be used like this

    Mock.Assert(() => _mock.ThisIsAMethod(Arg.AnyGuid), Occurs.Exactly(1));

    I hope someone knows the correct way to do this.

    Thanks in advance,
    Jeroen Speldekamp
  2. Ricky
    Ricky avatar
    467 posts

    Posted 21 Oct 2010 Link to this post

    Hi Jeroen,

    Thanks for the suggestion. Your suggested way for asserting occurrence for a property can be extremely useful. I am adding that to the backlog. Hopefully, it will be implemented soon.

    Mock.AssertSet(() => { _mock.Name = Arg.AnyString; }, Occurs.Exactly(2));

    Here is the PITS entry for the backlog item as well to let you track the progress of it.

    Kind Regards,
    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
  3. DevCraft R3 2016 release webinar banner
Back to Top