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
After upgrading from 4.0.1 to 4.2.2 several tests fail with a TypeMockException. I have recreated the problem in the small test example below.


        [TestMethod]
        public void FactoryTest() {
            MockManager.Init();
            Mock factorymock = MockManager.Mock(typeof(Factory));
            factorymock.ExpectAndReturn("Create", new StubForTypedComplexClass(), typeof(ISpecific));
            IGeneral<ISpecific> i = Factory.Create<ISpecific>();
            MockManager.Verify();
        }


    public static class Factory {
        public static IGeneral<T> Create<T>() {
            return new ComplexClass<T>();
        }
    }

    public interface ISpecific { }
    
    public interface IGeneral<T> { }

    public class ComplexClass<T> : IGeneral<T> { }

    public class StubForTypedComplexClass : IGeneral<ISpecific> { }


This is just dummy example code, but it does reproduce the problem. When run the test fails with the exception below:

Test method FactoryTest threw exception:  TypeMock.TypeMockException: 
*** No method Create<ISpecific> in type Factory returns StubForTypedComplexClass.


This works fine with 4.0.1.

I can mail the log files if you need them.

Regards,
Brian
asked by brian.rasmussen (7.2k points)

2 Answers

0 votes
Hi,

Indeed this looks likes a bug :evil:
We shall fix it and sendt you an update.
answered by lior (13.2k points)
0 votes
Hi Brian,

I also found out that writing the same test using using Natural Mocks works.
If its not too much work you might do that, until we can solve the problem.
answered by lior (13.2k points)
...