chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I am running into an odd problem that I have not been able to reproduce outside of my application. I have some unit tests exercising a specific method. There is a public method that is called within the tested method that I am verifying if it gets called or not depending on the code path. TypeMock is displaying some strange behavior when verifying that the public method was called.

When the method is not supposed to be called, Isolate.Verify.WasNotCalled fails and states that it was called unexpectedly. If I debug the unit test and step through the method, I see that I never go down the path that results in the public method being called.

When the method is supposed to be called, it does indeed get called. However, I am using Isolate.Verify.WithArguments to check the specific arguments that are passed to the method. When I set a breakpoint in there, I find that the arguments being passed to the method correspond to a completely different method that is called in the unit test. It is a different number of arguments than the public method and different types as well.

It seems that somehow TypeMock is treating the two methods as having the same name somehow. I recreated the same methods, classes, and unit tests in another solution and was unable to reproduce the issue.

Any suggestions?

Thanks,
Brian
asked by bhunter (3.4k points)

3 Answers

0 votes
Hi Brian,

If you're unable to recreate this, perhaps we could solve this in an online session. I'll contact you soon via our support, and perhaps we could schedule something up.
answered by igal (5.7k points)
0 votes
I have a unit test which has the line:
Isolate.Verify.WasNotCalled(() => VehicleParameters.spVMLSetVehicleChangeExpectedValue(null));

The spVMLSetVehicleChangeExpectedValue is being called once in the whole dll project
I have an internal servicehelper.cs which is visible to the test project by assemblyinfo([assembly: InternalsVisibleTo("Test.GRT.VML")])

Even if I write:
If(false)
VehicleParameters.spVMLSetVehicleChangeExpectedValue(vclParameters)

The “WasNotCalled” function returns:
Error:
Test method Test.GRT.VML.TestService.SetVehicleParameter_ArrayWithUnitParametersOnly_CentralDBWasNotCalled threw exception:
TypeMock.VerifyException:
TypeMock Verification: Method GRT.VML.DAL.VehicleParameters.GetVehicleUnitIds(Int32[]) was called unexpectedly

Stack:
ef.a(i3 A_0, aa A_1, hd A_2, Predicate`1 A_3)
b3.c(Delegate A_0)
b3.WasNotCalled[T](Func`1 func)
Test.GRT.VML.TestService.SetVehicleParameter_ArrayWithUnitParametersOnly_CentralDBWasNotCalled() in C:GreenroadTechSharedAssembliesMainGRT.VMLTest.GRT.VMLTestService.cs: line 235
TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
Test.GRT.VML.TestService.SetVehicleParameter_ArrayWithUnitParametersOnly_CentralDBWasNotCalled() in C:GreenroadTechSharedAssembliesMainGRT.VMLTest.GRT.VMLTestService.cs: line 195

THNX
Alon
answered by alonav (220 points)
0 votes
Hi Alon,

Can you please tell me:
1. Is spVMLSetVehicleChangeExpectedValue static method?
2. Are there any overloads for that method? If there are overloads please post the prototypes of the methods here.
answered by ohad (35.4k points)
...