Last Updated: 10 Jan 2014 09:04 by ADMIN
1. Load the attached project in Visual Studio 2013.
2. Update the NuGet packages (NUnit).
3. Update the reference to JustMock to point to the correct path to a retail version of Telerik.JustMock.dll.
4. Run tests in NUnit runner (or any other runner that will run them in the same process/sequentially.
5. --> Notice that the first TestCase will pass, the second will fail.
6. Run the two test cases separately.
7. --> Notice that they both pass.
8. Remove the reference to Telerik.JustMock.dll.
9. Use NuGet to get the latest JustMock Lite.
10. Run the tests again.
11. --> Notice that they both pass.

This appears to be a bug with JustMock (retail) 2013.3.1119.2.  The bug does not reproduce when using JustMock Lite from NuGet.

If you drop into a debugger and step through both tests in a row you see the following behavior:
1. When the first test is started (after SetUp has been called) FlagA is correctly set to true and FlagB is defaulted to false.
2. When you step over the Mock.Arrange, FlagA is still true and FlagB is set to the value of input (order of running tests doesn't appear to matter, second always fails).
3. When the second test starts (after SetUp has been called again) Flag A is correctly set to true and FlagB is defaulted to false.
4. When you step over the Mock.Arrange, FlagB is set to the value of input but FlagA has been reverted to default!

If you add several other properties to the interface they will all be reset to default (no matter how many you arrange) when the second test executes the Mock.Arrange.

This bug reproduces without the JustMock profiler attached, and also with the profiler attached.

The version of JustMock Lite that was tested against is 2014.1.1217.4.  When I run the Telerik Control Panel I am not prompted to update my version of JustMock beyond 2013.3.1119.2 (perhaps this bug is already fixed and I just need to figure out how to upgrade).
Last Updated: 06 Nov 2013 10:30 by Ovidiu

Since I upgraded my JustMock I was unable to debug ASP.NET projects. I accidentally found a resolution to the problem here:

"If you are using Telerik JustMock as a mocking framework and have recently updated it to the 2013 Q3 version, it causes this exact problem. I was able to resolve this issue by uninstalling the mocking framework and installing the 2013 Q2 version."

So I uninstalled JustMock and everything came to normal.

Last Updated: 04 Nov 2013 16:02 by ADMIN
using NUnit.Framework;
using Telerik.JustMock;

namespace Example
    public class MyClass
        public MyClass(int a = 5) { }

    public class TestMyClass
        public void test_MyClass()

Telerik.JustMock.MockException : Can not instantiate proxy of class: Example.MyClass.
Could not find a parameterless constructor.
   at Telerik.JustMock.Core.MocksRepository.Create(Type type, MockCreationSettings settings)
   at Telerik.JustMock.MockBuilder.Create(MocksRepository repository, Type type, Object[] constructorArgs, Nullable`1 behavior, Type[] additionalMockedInterfaces, Nullable`1 mockConstructorCall, IEnumerable`1 additionalProxyTypeAttributes, List`1 supplementaryBehaviors, List`1 fallbackBehaviors, List`1 mixins)
   at Telerik.JustMock.Mock.<>c__DisplayClass5b`1.<Create>b__5a()
   at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction)
   at Telerik.JustMock.Mock.Create[T](Behavior behavior, Object[] args)
   at Example.TestMyClass.test_MyClass() in c:\users\micah\Documents\Source\Test\Test\Class1.cs:line 17#0

This appears to be related to the recent fix for "Improve exception message for Mock.Create".  Without Behavior.CallOriginal it works.  Supplying a parameter also works.
Last Updated: 04 Nov 2013 15:55 by ADMIN
Created by: Thomas
Comments: 3
Type: Bug Report
I need to be able to mock in Winrt. If that is already possible, then you need to spell out in example form how that is done.
Last Updated: 27 Aug 2013 06:39 by Omer
Created by: Omer
Comments: 0
Type: Bug Report
Hi there, I'm a developer on OzCode, a Visual Studio extension ( ).

We've received some complaints from customers that OzCode is incompatible with JustCode. I installed JustMock, and saw that when Visual Studio starts up, JustMock it seems to be causing a crash in a child process that OzCode spawns off of devenv.exe, which is called 'BugAidMetadataLoader.exe':

The exception in this process is:

Additional information: Could not load type 'Telerik.JustMock.Profiler' from assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

I would guess that JustMock is unintentionally causing the process to be loaded with a CLR Profiler attached and injecting code into it, and the injected code causes the crash.

Could you please provide some advice on how to avoid this, or possibly provide a fix?

Thank you very much,
 - Omer Raviv, OzCode
Last Updated: 17 May 2013 12:44 by Jakub
When I try to invoke method from intercepted class in multi-thread test sometimes I get following exception:
Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at System.Collections.Generic.List`1.CopyTo(T[] array, Int32 arrayIndex)
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList(IEnumerable`1 source)
   at Telerik.JustMock.Weaver.ContainerContext.InstanceIdentifier.GetUniqueId(Object target)
   at Telerik.JustMock.Weaver.ContainerContext.Get(Type targetType, MethodBase methodInfo, Object target)
   at Telerik.JustMock.Weaver.ContainerContext.Get(MethodBase methodBase, Object target)
   at Telerik.JustMock.Weaver.Interceptors.WeaverInterceptor.OnInvocation(IInvocation invocation)
   at Telerik.JustMock.Weaver.Interceptors.WeaverInterceptor.Telerik.JustMock.Weaver.Interceptors.Abstraction.IWeaverInterceptor.Intercept(IInvocation invocation)
   at TestClass_Interceptor_620e5e80fe0c4d738f7ef291ea50ea2a.Intercept(TestClass, ref Boolean)
   at ExceptionExample.TestClass.ExecuteSomething() in Test.cs: line 174
   at ExceptionExample.RunMethod() in Test.cs: line 199
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Sample class that generates exception:

public class ExceptionExample
	static ExceptionExample()

	public class TestClass
		public void ExecuteSomething()
			int y = 0;
			for (int i = 0; i < 100; i++)
				y += i;

	public void MethodName()
		List<Thread> l = new List<Thread>();

		for (int i = 0; i < 6; i++)
			Thread t = new Thread(RunMethod);

		l.ForEach(th => th.Join());

	private void RunMethod()
		for (int i = 0; i < 10000; i++)
			TestClass tc1 = new TestClass();
Last Updated: 17 May 2013 12:29 by Mohd
Created by: Mihail
Comments: 1
Type: Bug Report
Since JustMock Q1 2013 Mock.DoNotUseProfiler() is marked as an obsolete method and I cannot compile my test project. Revert it back.
Last Updated: 17 May 2013 12:23 by David
I'm getting this argument exception:
System.ArgumentException : The type or method has 3 generic parameter(s), but 2 generic argument(s) were provided. A generic argument must be provided for each generic parameter.
   at System.RuntimeType.SanityCheckGenericArguments(RuntimeType[] genericArguments, RuntimeType[] genericParamters)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   at .š.(Type ‹, MethodBase „†, BindingFlags )
   at .š.(Type ‚, MethodBase „†)
   at ”.“.Create(Object š, MethodInfo ›, Boolean ’)
   at ..(˜ )
   at ..(Expression`1 )
   at Telerik.JustMock.Mock..Ž( )
   at ..—[,—]( , Func`2 )
   at Telerik.JustMock.Mock.Arrange[TResult](Expression`1 expression)

Heres an example of a failing test:

        public void GenericTestCanMockTwoGenericMethods()
            var mocked = Mock.Create<GenericTest>();
            IEnumerable<EVENT_CODE> n = null;
            Mock.Arrange(() => mocked.Query<EVENT_CODE, ALARM_CODE>(Arg.AnyString, Arg.IsAny<object>())).Returns(n).MustBeCalled();

        public interface GenericTest
            IEnumerable<T1> Query<T1, T2>(string arg1, params object[] args);

            IEnumerable<T1> Query<T1, T2, T3>(string arg1, params object[] args);
Last Updated: 22 Nov 2012 15:00 by Philip Japikse
If I have a constructor like this: public Foo(IAccount fromAccount, IAccount toAccount) { //code }, I need to be able to distinguish between the two accounts when automocking.
container.Arrange<IAccount>() won't work.  Perhaps container.Arrange<IAccount>[0] would. 
1 2 3