This project is read-only.

Faking properties and method calls using Isolate.WhenCalled

Sep 15, 2009 at 3:42 AM
Edited Sep 15, 2009 at 3:45 AM

I need to fake WebClient instances and DownloadStringCompletedEventArgs instances this is in order to simulate calls to property such as DownloadStringCompletedEventArgs.Error & DownloadStringCompletedEventArgs.Result

var fakeWebClient = Isolate.Fake.Instance<WebClient>();

var fakeDownloadStringCompletedEventArgs = Isolate.Fake.Instance<DownloadStringCompletedEventArgs>();



Isolate.WhenCalled(() => fakeDownloadStringCompletedEventArgs.Error).WillReturn(null);

Isolate.WhenCalled(() => fakeDownloadStringCompletedEventArgs.Result).WillReturn("some string response"); 

But as you might guess or know this won't let the test run already. I guess the reason is because now I am referencing System.Core for silverlight! Do you have any workaround for this?

Sep 15, 2009 at 1:57 PM


Why not post this question to the TypeMock forums?


Sep 15, 2009 at 2:14 PM

Yes Sure I will. Just thought it is related to CThru & SilverUnit! that is why I posted here. Will post it on TypeMock forum now.