Frage

I've seen samples using Moles to redirect DateTime.Now but when I tried to redirect System.Net.Sockets.TcpClient.GetStream I couldn't make the corresponding MTcpClient appear on Intellisense.

Is there a limited number of classes which methods Moles can redirect? Is there any step that I missed?

War es hilfreich?

Lösung

First, it's System.Net.Sockets.Moles.MTcpClient, don't forget the Moles namespace.

Second, there seems to be a quirk when mocking Core.dll: after adding the .moles file for this assembly the usual way (by right-clicking the reference in Solution Explorer) you need to modify it to look like this:

<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
  <Assembly Name="System" ExportedTypes="true" ReflectionOnly="true" />
</Moles>

or else you might get build errors as described in this question.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top