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
Dear Typemock team,

The following code can be executed and passes in VS2010 but fails in VS2012:

namespace ConsoleApplication1
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TypeMock.ArrangeActAssert;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class TestProgram
{
[TestMethod]
public void TestTypemock()
{
Uri fakeUri = new Uri("http://www.ecarinsurance.co.uk");
ISessionDetails fakeSessionDetails = new SessionDetails(fakeUri);
Isolate.WhenCalled(() => fakeSessionDetails.AbsoluteUrl).WillReturn(fakeUri);
}
}

/// <summary>
/// Represents session details returned by provider
/// </summary>
public interface ISessionDetails
{
/// <summary>
/// Gets Url concatenated with Session id for card capture
/// </summary>
Uri AbsoluteUrl { get; }
}

public class SessionDetails : ISessionDetails
{
/// <summary>
/// Initialises a new instance of the <see cref="SessionDetails"/> class.
/// </summary>
/// <param name="absoluteUrl">The absolute Uri of the session.</param>
public SessionDetails(Uri absoluteUrl)
{
this.AbsoluteUrl = absoluteUrl;
}

/// <summary>
/// Gets the URI of the Access Control Server - the issuing bank's server that does the 3DS check with the cardholder.
/// </summary>
public Uri AbsoluteUrl { get; private set; }
}
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The output is:

Test Name: TestTypemock
Test FullName: ConsoleApplication1.TestProgram.TestTypemock
Test Source: UnitTest1.cs : line 15
Test Outcome: Failed
Test Duration: 0:00:00.7889189

Result Message:
Test method ConsoleApplication1.TestProgram.TestTypemock threw exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: uriString
Result StackTrace:
at System.Uri..ctor(String uriString)
at gc.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, StackTrace A_6)
at gc.a(Mock A_0, String A_1, Object A_2, MethodBase A_3, Object[] A_4, Object A_5, bq A_6)
at gc.a(Object A_0, MethodBase A_1, Object[] A_2, bq A_3, String A_4, Mock A_5, Object A_6, String A_7)
at gc.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMock.MockManager.getReturn(Object context, String typeName, String methodName, Object methodGenericParams, Boolean isDecorated, Boolean isInterceptedType, Object[] methodArguments)
at Typemock.Interceptors.Profiler.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
at ConsoleApplication1.SessionDetails.get_AbsoluteUrl()
at ConsoleApplication1.TestProgram.<>c__DisplayClass1.<TestTypemock>b__0() in UnitTest1.cs:line 18
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at gj.c()
at bh.a(Boolean A_0)
at dl.b(Boolean A_0)
at ik.b(Boolean A_0)
at ik.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5, Boolean A_6)
at ik.e(Object A_0)
at TypeMock.ArrangeActAssert.ExpectationEngine`1.a(TResult A_0)
at ConsoleApplication1.TestProgram.TestTypemock() in UnitTest1.cs:line 18





This is the final issue I face in upgrading our development environment.

Thankyou for your support so far,

John
asked by Slavo (2.4k points)

8 Answers

0 votes
Hi,

Thanks for the report. I'm trying to reproduce it.

Are you using .NET 4/4.5 in both VS 2010 and VS 2012?
answered by Elisha (12k points)
0 votes
It can be reproduced by copying the code, pasting into a unit test project and referencing Typemock 7.1.2.0.

It doesn't make a difference which .NET Framework is used (easily changed by a single dropdown in the project properties window, under 'Application' tab on the left-hand side and changing the 'Target framework'):

VS2010 does not target .NET 4.5.

VS2010 - .NET 3.5 PASS
VS2010 - .NET 4.0 PASS

VS2012 - .NET 3.5 FAIL
VS2012 - .NET 4.0 FAIL
VS2012 - .NET 4.5 FAIL

I cannot do anything more to help you than this.

Regards,

John
answered by Slavo (2.4k points)
0 votes
Hi John,

Thank you for this.
We will look into this case and update you ASAP.
answered by alex (17k points)
0 votes
Hi,

We've fixed the bug. The fix will be part of the next release, 7.1.4.

Meanwhile the attached file can be used, please place it in the install directory of Isolator instead of the file that exists there.

Please let me know if it works.

namespaces.dat
answered by Elisha (12k points)
0 votes
Hi there,

I can confirm that this makes the unit test code I posted originally now pass. We are still experiencing the same symptoms for a few of our tests but I suspect this is being caused by another issue I'm yet to investigate.

Thankyou for your prompt fix,

John
answered by Slavo (2.4k points)
0 votes
Hi John,

Thank you for the update.
Please share the conclusions of your investigation with us :D
answered by alex (17k points)
0 votes
Hi John,

Just to let you know that this fix is included in V 7.1.5 which was released yesterday.
answered by alex (17k points)
0 votes
Hi.
I have the same issue with Typemock 7.4 and VS 2012 Update 3 on Windows Server 2008 R2 Standart.
Are you sure, that your fix is still work?
answered by Grigory (1.3k points)
...