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

Assert() and Arrange()

1 Answer 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Suneco
Top achievements
Rank 2
Suneco asked on 15 Oct 2010, 03:56 PM
Hello,

I got a question or sort of functionallity request.
After a little while working with JustMock, I found out that the Assert(action) communicates with Arrange(action).

I will show you a sample of how the code works how it is now

//Arrange
Mock.Arrange(() => _mock.ThisIsAMethod(module, moduleSetting1.Name)).Returns(moduleSetting1.Value).MustBeCalled();
Mock.Arrange(() => _mock.ThisIsAMethod(module, moduleSetting2.Name)).Returns(moduleSetting2.Value).MustBeCalled();
Mock.Arrange(() => _mock.ThisIsAMethod(module, moduleSetting3.Name)).Returns(moduleSetting3.Value).MustBeCalled();
  
//Act
_presenter.Load();
  
//Assert
Mock.Assert(() => _mock.ThisIsAMethod(module, moduleSetting1.Name), Occurs.Exactly(1));
Mock.Assert(() => _mock.ThisIsAMethod(module, moduleSetting2.Name), Occurs.Exactly(1));
Mock.Assert(() => _mock.ThisIsAMethod(module, moduleSetting3.Name), Occurs.Exactly(1));

Well in the sample I got 3 module settings but in the real code i got like 12. Now I want to validate how much times it is cast with 1 code rule not 12. I thougth about the below solution but it always says it has been called once.

//Arrange
Mock.Arrange(() => _mock.ThisIsAMethod(module, moduleSetting1.Name)).Returns(moduleSetting1.Value).MustBeCalled();
Mock.Arrange(() => _mock.ThisIsAMethod(module, moduleSetting2.Name)).Returns(moduleSetting2.Value).MustBeCalled();
Mock.Arrange(() => _mock.ThisIsAMethod(module, moduleSetting3.Name)).Returns(moduleSetting3.Value).MustBeCalled();
  
//Act
_presenter.Load();
  
//Assert
Mock.Assert(() => _mock.ThisIsAMethod(module, Arg.AnyString), Occurs.Exactly(3));

This woulth be a good solution because it saves me a lot of code. Hope this is possible some how or will be possible in the next update.

Thanks in advance,
Jeroen Speldekamp

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 18 Oct 2010, 09:07 AM

Hi Jeroen,

Thanks for the great feature suggestion. I have already added that to the backlog and hopefully it will be included in coming release.

You can further monitor the progress of the task using the following PITS entry:
http://www.telerik.com/support/pits.aspx#/public/justmock/3749

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