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
I'm using Isolator 6.0.6 and the following code generates an exception.



public void CompileTimeValidate_MethodIsAbstract_ReturnFalse() {
         var fakeMethod = Isolate.Fake.Instance<MethodBase>();
         Isolate.WhenCalled(() => fakeMethod.DeclaringType).WillReturn(typeof(ChargerBase));
         Isolate.WhenCalled(() => fakeMethod.IsAbstract).WillReturn(true);
         var aspect = new RaiseEventWhenChargerActionFailsAttribute();

         var result = aspect.CompileTimeValidate(fakeMethod);

         Assert.IsFalse(result);
      }

I get the exception:

Test method BetterPlace.Bxs.Server.Cms.Tests.RaiseEventWhenChargerActionFailsAttributeTests.CompileTimeValidate_MethodIsAbstract_ReturnFalse threw exception: System.InvalidCastException: Specified cast is not valid..

Regards,

Gur
asked by gurkashi (600 points)

1 Answer

0 votes
Hello,

Unfortunately you're trying to fake a type in mscorlib, something which we don't yet fully support.

I am trying to come up with a workaround in the mean time, let me get back to you on that...

There should be a better error message for this! I'll add this to our backlog in the mean time.

I apologize for the inconvenience... :(
answered by igal (5.7k points)
...