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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
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
asked by JamesKing (8.2k points)

1 Answer

0 votes
Hi James,

You can find a fix for this in latest release of Isolator.

You can download it from https://www.typemock.com/download.
answered by Shai Barak (1.5k points)
...