Hi,
The Verify in the following code does not specify the mismatching arguments:
----Error Message
Test method
Typemock.Demo.ASP.Net.HTTPContextTest.WriteBoldNameToBrowser_FakeHTTPCon
text_WritesBold threw exception:
TypeMock.VerifyException:
TypeMock Verification: Method HttpContext.Current.Response.Write(String)
was called with mismatching arguments
Expected: get_Response()
Actual: get_Response()
--- Error Message
---code---
using System;using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TypeMock.ArrangeActAssert;
namespace Typemock.Demo.ASP.Net
{
/// <summary>
/// Summary description for HTTPContext
/// </summary>
[TestClass]
[Isolated]
public class HTTPContextTest
{
[TestMethod]
public void WriteBoldNameToBrowser_FakeHTTPContext_WritesBold()
{
Isolate.WhenCalled(()=>HttpContext.Current).ReturnRecursiveFake();
//Isolate.Fake.StaticMethods<HttpContext>();
ResponseWriter writer = new ResponseWriter();
writer.WriteBoldNameToBrowser("test");
Isolate.Verify.WasCalledWithExactArguments(() =>
HttpContext.Current.Response.Write("<b>test</b>"));
}
[TestMethod]
public void
WriteBoldNameToBrowser_SimulateException_ReturnFalse()
{
Isolate.WhenCalled(()=>HttpContext.Current).WillThrow(new
Exception());
ResponseWriter writer = new ResponseWriter();
Assert.IsFalse(writer.WriteBoldNameToBrowser("test"));
}
}
public class ResponseWriter
{
public bool WriteBoldNameToBrowser(string name)
{
string boldName = "<b>" + name + "<b>";
try
{
HttpContext.Current.Response.Write(boldName);
}
catch
{
return false;
}
return true;
}
}
}
Thanks,
-JK