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