Skip to content

Calling a method that does not exists doesn't throw explicit exception #5

@jupaol

Description

@jupaol

Hi

I was using the code directly in my application and I just migrated to use the Nuget, all my tests seem to pass except this one: (it was green before updating to use the Nuget)

        [TestMethod]
        public void it_should_throw_an_exception_if_the_method_does_not_exist()
        {
            var originalObject = new SimpleObject();
            var sut = originalObject.AsDynamic();
            Action a = () => sut.DoesNotExistMethod("dede");

            a.ShouldThrow<MissingMethodException>().WithMessage("*DoesNotExistMethod*");
        }

Instead it throws:

Result Message: 
Expected a <System.MissingMethodException> to be thrown, but found a <System.ApplicationException>: System.ApplicationException with message "Error in the application."
     at ReflectionMagic.PrivateReflectionDynamicObjectBase.InvokeMethodOnType(Type type, Object target, String name, Object[] args, IList`1 typeArgs)
     at ReflectionMagic.PrivateReflectionDynamicObjectBase.InvokeMethodOnType(Type type, Object target, String name, Object[] args, IList`1 typeArgs)
     at ReflectionMagic.PrivateReflectionDynamicObjectBase.InvokeMethodOnType(Type type, Object target, String name, Object[] args, IList`1 typeArgs)
     at ReflectionMagic.PrivateReflectionDynamicObjectBase.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
     at CallSite.Target(Closure , CallSite , Object , String )
     at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)

It's not high severity, I just wanted to let you know

Good job, I love this tool

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions