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
I have a case where an argument mismatch is causing a call to Isolate.Verify.WasCalledWithExactArguments to throw an exception, with an incorrect error message. Here is a minimal repro:

The class being tested:
namespace MyProductCode
{
    public class C
    {
        public void F(D d)
        {
            d.G(1, new string[0]);
        }
    }

    public class D
    {
        public void G(int n, string[] args)
        {
        }
    }
}

The unit test. Note that the first parameter to the call to d.G is 2, where it should be 1:
using MyProductCode;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TypeMock.ArrangeActAssert;

namespace TestProject
{
    [TestClass, Isolated]
    public class UnitTest
    {
        [TestMethod]
        public void TestMethod()
        {
            C c = new C();
            D d = Isolate.Fake.Instance<D>();
            string[] emptyArgs = new string[0];

            c.F(d);

            Isolate.Verify.WasCalledWithExactArguments(() => d.G(2, emptyArgs));
        }
    }
}

The exception, thrown from Isolate.Verify.WasCalledWithExactArguments:
Test method TestProject.UnitTest.TestMethod threw exception:  System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length.

I expect instead an error message telling me of the mismatched argument between "2" and "1".

Thanks,
Larry
asked by lgolding@microsoft.c (4k points)

2 Answers

0 votes
You're absolutely right - I'll add a defect report to our development plan
answered by dhelper (11.9k points)
0 votes
Ok, thanks -- Larry
answered by lgolding@microsoft.c (4k points)
...