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
If I have a class with overloaded constructors which call other constructors using : this() syntax I get the following error:

Rbsfm.VTradeWeb.Core.TestClass.MockTest : System.ArgumentException : Item has already been added.  Key in dictionary: "TypeMock.e"  Key being added: "TypeMock.e"


e.g.
using System.Collections;
using NUnit.Framework;
using TypeMock;

namespace TypeMock.BugTest
{
    public interface MockInterface
    {}

    public class MockClass : MockInterface
    {
        public MockClass() : this(null)
        {}

        public MockClass(ArrayList list)
        {}
    }

    [TestFixture]
    public class TestClass
    {
        [Test]
        public void MockTest()
        {
            MockManager.Init();

            Mock mock = MockManager.Mock(typeof(MockClass));

            MockInterface mockClass;

            mockClass = new MockClass();
            mockClass = new MockClass();
        }
    }
}


The problem dissappears when the : this(null) is removed....

The problem also dissappears if I keep the : this(null) but only instantiate a single mock class but I had believed that using .Mock only mocked the *next* instance of a type....

I figure this is a bug :evil: but want to check first.... any help appreciated!
asked by c0d3-m0nk3y (8.7k points)

1 Answer

0 votes
Hi,
This has been solved in version 3.0.1
Please upgrade :-)
answered by scott (32k points)
...