Duplicat Type Name with Assembly Exception

Eric
2008-09-30
2013-04-29
  • Eric
    Eric
    2008-09-30

    So after getting everything changed over I have major issues with tests passing now.  I get a lot of my tests failing for a Duplicate Type Name with Assembly exception coming out of some CheckTypeNameConflict function the .net Reflect namespace.

    I have this snippet for an example of a fixture that will fail with this:

    [TestFixture]
        public class TestPowertrainMotorPropertyConverter
        {
            private PowertrainMotorPropertyConverter converter;
            private IPropertiesLocalizer localizer;

            [SetUp]
            public void SetUp()
            {
                localizer = (PropertiesLocalizer)(new Mockery().NewMock(typeof(PropertiesLocalizer)));

                converter = new PowertrainMotorPropertyConverter();
            }

            //
            // TESTS
            //

            [Test]
            public void test_ConvertTo()
            {
                ArrayList pairs = PowertrainMotorModeEnumConverter.GetHumanReadablePairs();

                foreach (EnumHumanReadablePair pair in pairs)
                {
                    PowertrainMotorData data = new PowertrainMotorData();
                    data.Mode = (PowertrainMotorMode)pair.Value;
                   
                    PowertrainMotorProperty property = new PowertrainMotorProperty(localizer, data);

                    string gotName = (string)converter.ConvertTo(property, typeof(string));
                    Assert.AreEqual("Motor Mode: " + pair.HumanReadableName, gotName, "wrong name");
                }
            }

    Does anyone know what is wrong with what I am doing?

    Thanks

    Eric

     
    • Urs Enzler
      Urs Enzler
      2008-09-30

      Hi Eric

      Could you please provide a complete (minimal) unit test including the class you are testing?
      Otherwise we don't know how to reproduce your problem.

      If it is too large for the forum, please send your code to ursenzler at users.sourceforge.net and I'll take a look at it.

      Thanks
      Urs

       
    • Eric
      Eric
      2008-09-30

      I was trying to mock a class and not an Interface.  It was fat finger on my part.  It took me some time but I figured it out.

      Thanks.

      I do have another question that I am starting on a new thread about the old IsCloseTo constraint.

      Eric

       
      • Urs Enzler
        Urs Enzler
        2008-10-01

        Hi Eric

        I'll have a look at the code whether we should throw a clearer exception that says that an interface type is required.

        Happy mocking
        Urs

         
    • Urs Enzler
      Urs Enzler
      2008-10-01

      I improved the exception message that is shown if a class is mocked. You can find this in revision 70 in our svn repository.

      Happy mocking
      Urs