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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi

the following throws an exception
[Test]

        public void Test_If_Mime_IsSupported()
        {
            
            var myWebResponse = Isolate.Fake.Instance<cc>();
            Isolate.WhenCalled(() => myWebResponse.ContentType).WillReturn("text");
            

        }
    }
    public class cc
    {
        public string ContentType;
    }
asked by (28.8k points)

1 Answer

0 votes
Hi Tolisss,

It doesn't crash as a whole, and at least give you a better message.

You are trying to set behavior on a field. WhenCalled works only on methods and properties. You should wrap the field with a property for that to work.

Thanks,
answered by (14.5k points)
...