I have a unit test where I assert that a certain action will call a method on a mock dependency object by using Mock.Assert(). I want to ensure that the action I take calls the method on the mock object exactly once. The problem is that the setup of the unit test creates a scenario where the method of the mock object will also be called, so when I assert that the call to the mock object happened just once it fails because it has actually been called more than once. Is there a way to "reset" the call tracking of methods on mock objects? I basically want to tell JustMock that at a certain point, whatever calls have happened to my mock objects should be discarded and the call counter should basically start at 0 again.
Using InOrder() in the arrange sometimes may be not appropriate. I would like to be able to do this in the assert. Instead of having the following workflow: //Arrange (initial conditions) // setup expected results (ordering) // Act // Assert , I will have this: //Arrange //Act // Assert (expected results in order)
Allow the developer to create custom behaviors and use them in an arrangement. Something like the following:
Mock.Arrange(() => foo.CalcData(Arg.AnyInt, Arg.AnyInt), new IBehavior[]
{
new LogInvocation(),
new ReturnBaseOrDefaultValue(),
});
I am using Visual Studio 2015, Crystal Reports 12.0.2. When running from Visual Studio in debug mode or not, the application hangs on the statement "new ReportDocument()". ReportDocument is a class defined in CrystalReports. When I disabled the JustMock Profiler, this statement no longer hung. Just FYI. Hopefully others will see this.
If I define a fluent API, I might have an interface such as this: public interface IRegistrar { IRegistrar UsingThis(object someThing); IRegistrar UsingThat<TThatThing>() } If I create a mock of this using the default Behaviour.RecursiveLoose and make no arrangements, calls to the methods will return new mocks of the type, rather than the same instance that was called. It would be nice to have a behaviour type that can return the same instance (in this case the mocked instance) without having to define a stub for each method call. My code under test might look like: IRegistrar reg; reg .UsingThis(new object()) .UsingThat<int>(); Currently, a test on the second call will fail if written against the mock assigned to 'reg'.
I want to check the order of methode calls but InSequence() does not work for it.
Does Telerik JustMock work for Windows 8.1 environment? We have a solution targeting Windows 8.1. I haven't been able to use Telerik JustMock. Is there any workaround to make it work or some planned release for this framework. Best regards, Sebas