This is a migrated thread and some comments may be shown as answers.

Occurs.Exactly() possible with AssertSet() ?

1 Answer 24 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Suneco
Top achievements
Rank 2
Suneco asked on 14 Oct 2010, 12:57 PM
Hello,

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

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 21 Oct 2010, 11:15 AM

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.
http://www.telerik.com/support/pits.aspx#/public/justmock/3784


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
Tags
Code Analysis
Asked by
Suneco
Top achievements
Rank 2
Answers by
Ricky
Telerik team
Share this question
or