Completed
Last Updated: 04 Nov 2013 16:02 by ADMIN
Micah
Created on: 21 Oct 2013 23:08
Type: Bug Report
1
Mock.Create exception on constructor with default parameters.
using NUnit.Framework;
using Telerik.JustMock;

namespace Example
{
    public class MyClass
    {
        public MyClass(int a = 5) { }
    }

    [TestFixture]
    public class TestMyClass
    {
        [Test]
        public void test_MyClass()
        {
            Mock.Create<MyClass>(Behavior.CallOriginal);
        }
    }
}

Telerik.JustMock.MockException : Can not instantiate proxy of class: Example.MyClass.
Could not find a parameterless constructor.
   at Telerik.JustMock.Core.MocksRepository.Create(Type type, MockCreationSettings settings)
   at Telerik.JustMock.MockBuilder.Create(MocksRepository repository, Type type, Object[] constructorArgs, Nullable`1 behavior, Type[] additionalMockedInterfaces, Nullable`1 mockConstructorCall, IEnumerable`1 additionalProxyTypeAttributes, List`1 supplementaryBehaviors, List`1 fallbackBehaviors, List`1 mixins)
   at Telerik.JustMock.Mock.<>c__DisplayClass5b`1.<Create>b__5a()
   at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction)
   at Telerik.JustMock.Mock.Create[T](Behavior behavior, Object[] args)
   at Example.TestMyClass.test_MyClass() in c:\users\micah\Documents\Source\Test\Test\Class1.cs:line 17#0

This appears to be related to the recent fix for "Improve exception message for Mock.Create".  Without Behavior.CallOriginal it works.  Supplying a parameter also works.
1 comment
ADMIN
Vladi
Posted on: 04 Nov 2013 16:02
This exception is fixed in our latest public version 2013.3.1101.2. Please give it a try and let us know what you think.