Telerik Forums
JustMock Forum
6 answers
232 views
VS 2012 +Update 2
.NET 4.5 C# Project
JustMock 2013 Q2
NCrunch
ReSharper

With both NUnit and MSpec unit tests I am constantly receiving a "System.BadImageFormatException : Index not found."

Simple profiled mock:
var config = Mock.Create<ApplicationConfigurationBase>();
Mock.Arrange(() => config.CompositionContainer).Returns(
new CompositionContainer());

It doesn't matter if I use NCrunch or ReSharper's test runner. Both display the exception. I followed the documentation given for NCrunch integration. I've also tried the JustMock_2013.2.624_Dev internal build which led to even worse results and erratic behavior.

Any ideas on how to solve this issue would be much appreciated.

Thanks!
Kaloyan
Telerik team
 answered on 27 Jun 2013
3 answers
114 views
What is the status for VS2012 CodeCoverage and JustMock?

Some of my smaller projects work as expected, but my larger projects still throw errors when I try to mock/assert something.
Kaloyan
Telerik team
 answered on 25 Jun 2013
13 answers
165 views
Hi

I'm evaluating JustMock and notice it doesn't play well with NCrunch when using elevated mode. Given that NCrunch is a great tool, I was wondering if there is anything you could do to help. The following link highlights the problem the developers are having:
http://forum.ncrunch.net/yaf_postsm2596_Using-NCrunch-with-JustMock.aspx?find=unread#post2596 

Thanks
Russell Mason
Kaloyan
Telerik team
 answered on 14 Jun 2013
1 answer
66 views
Why the only JustMock setup requires to quit SQL Server Management Studio?
Kaloyan
Telerik team
 answered on 13 Jun 2013
1 answer
201 views
Couldn't figure out why this is happening.

System.TypeLoadException was unhandled by user code
  HResult=-2146233054
  Message=Method 'InternalToString' on type 'HttpEntityExceptionProxy+644d129a7a854c8c9d115708bc631cd4' from assembly 'Telerik.JustMock.Dynamic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that is not visible from that assembly.
  Source=mscorlib
  TypeName=HttpEntityExceptionProxy+644d129a7a854c8c9d115708bc631cd4
  StackTrace:
       at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
       at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
       at System.Reflection.Emit.TypeBuilder.CreateType()
       at    .   .   ()
       at Telerik.JustMock.DynamicProxy.Proxy.   ()
       at Telerik.JustMock.DynamicProxy.ProxyFactory.Create()
       at Telerik.JustMock.DynamicProxy.Fluent.FluentProxy.NewInstance()
       at Telerik.JustMock.DynamicProxy.Proxy.Create(Type type, Action`1 action)
       at    .   .   (Type   ,      )
       at    .   .   (     )
       at    .   .   (Behavior    , Boolean    )
       at    .   .   ()
       at Telerik.JustMock.FluentMock.Create()
       at Telerik.JustMock.Mock.Create(Type target, Action`1 settings)
       at Telerik.JustMock.Mock.Create(Type targetType, Constructor constructor, Behavior behavior)
       at Telerik.JustMock.Mock.Create[T](Constructor constructor)
       at Tests.HttpEntityExceptionExtensions_GetExceptionMessage_with_null_Response_returns_null() in c:\HttpEntityExceptionExtensionsTests.cs:line 34

// works fine.
var test = Mock.Create<HttpRequestException>(Constructor.Mocked);
 
// throws exception
var exception = Mock.Create<HttpEntityException>(Constructor.Mocked);
 
// HttpRequestException is from NuGet Package Microsoft.Net.Http.2.1.10
public class HttpEntityException : HttpRequestException
{
    public HttpEntityException(HttpResponseMessage response)
        : base(response.ReasonPhrase)
    {
        this.Response = response;
    }
 
    public HttpStatusCode StatusCode { get { return this.Response.StatusCode; } }
 
    public HttpResponseMessage Response { get; private set; }
}

Currently have JustMock_2013.2.603_Dev.msi installed.

Kaloyan
Telerik team
 answered on 11 Jun 2013
8 answers
215 views
Hello, I started to get this message, I guess since I installed a test version of JustMock. But the project which throws the error does not use JustMock for anything, and does not have any references to it

Could not load file or assembly 'Telerik.CodeWeaver.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=87210992829a189d' or one of its dependencies.....
Kaloyan
Telerik team
 answered on 11 Jun 2013
16 answers
194 views
In the following code unable to mock the static class- Thanks in advance for kind act
[TestClass]
   public class FooTest
   {
       [TestMethod]
       public void Test_MockStaticClass()
       {
    //By no means able to Mock the below static class
        Mock.SetupStatic(typeof(Foo), Behavior.Loose, StaticConstructor.Mocked);//gives error of constraint
          
       }
   }
 
   public static class Foo
   {
       static Foo() { }
       public static List<T> AllFoos<T>() where T : Base, ICloneable
       {
           return new List<T>();
       }
   }
   [Serializable]
   [DataContract]
   public abstract class Base
   {
       public Base() { }
   }
Kaloyan
Telerik team
 answered on 10 Jun 2013
1 answer
148 views
var content = Mock.Create<HttpContent>();

throws:

System.TypeLoadException was unhandled by user code
  HResult=-2146233054
  Message=Method 'TryComputeLength' in type 'HttpContentProxy+8f0c5d24e08246c69d913c472013ba3d' from assembly 'Telerik.JustMock.DynamicStrong, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8b221631f7271365' does not have an implementation.
  Source=mscorlib
  TypeName=HttpContentProxy+8f0c5d24e08246c69d913c472013ba3d
  StackTrace:
       at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
       at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
       at System.Reflection.Emit.TypeBuilder.CreateType()
       at    .   .   ()
       at Telerik.JustMock.DynamicProxy.Proxy.   ()
       at Telerik.JustMock.DynamicProxy.ProxyFactory.Create()
       at Telerik.JustMock.DynamicProxy.Fluent.FluentProxy.NewInstance()
       at Telerik.JustMock.DynamicProxy.Proxy.Create(Type type, Action`1 action)
       at    .   .   (Type   ,      )
       at    .   .   (     )
       at    .   .   (Behavior    , Boolean    )
       at    .   .   ()
       at Telerik.JustMock.Mock.Create(Type target, Behavior behavior, Object[] args)
       at Telerik.JustMock.Mock.Create(Type target, Object[] args)
       at Telerik.JustMock.Mock.Create[T]()
       at TEST() in c:\xxx.cs:line 61
  InnerException: 

Kaloyan
Telerik team
 answered on 10 Jun 2013
3 answers
89 views
I cannot find a way to actually have my mock work.

Given code like this:

[Test]
public void DirectoryTest()
{
    Mock.SetupStatic(typeof (Directory), Behavior.CallOriginal, StaticConstructor.Mocked);
    Mock.Initialize(typeof (Directory)); // w/ or w/o this line - same behavior
 
 
    Mock.Arrange(() => Directory.GetDirectories(Arg.AnyString, Arg.AnyString, Arg.IsAny<SearchOption>()))
        .IgnoreArguments() // w/ or w/o this line - same behavior
        .IgnoreInstance() // w/ or w/o this line - same behavior
        .Returns(() => new[] {"somedummydirectory"});
 
    // throws ArgumentNullException here
    var test = Directory.GetDirectories(null, "*", SearchOption.TopDirectoryOnly).ToList();
    Assert.IsNotNull(test);
    Assert.AreEqual(1, test.Count);
    Assert.AreEqual("somedummydirectory", test[0]);
}


What am I missing? (using NUnit 2.6.2 with the Resharper test runner).
Kaloyan
Telerik team
 answered on 07 Jun 2013
7 answers
291 views
All tests run fine when my Test Settings are set to Local.testsettings.  But when I switched to using CodeCoverage.runsettings (so I can configure my code coverage settings), I get the "profiler is not enabled" error message.

I am using the default runsettings example file found here: http://msdn.microsoft.com/en-us/library/jj635153.aspx

Q: Is is possible to use JustMock profiler with runsettings?

Visual Studio Premium 2012.
Kaloyan
Telerik team
 answered on 05 Jun 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?