Frage

Guten Nachmittag

Ich habe eine Klasse und es hat eine zugehörige Erweiterungsmethode. generasacodicetagpre.

Erweiterungsmethode: generasacodicetagpre.

Ich versuche jetzt, Rhino zu verwenden und diese Methode zu testen generasacodicetagpre.

Angenommen, ich schreibe meinen Test und habe bereits eine Schnittstelle, die getPERSONINFO () ruft generasacodicetagpre.

und der Hauptgeld ist generasacodicetagpre.

Wie kann ich einen Test für die Erweiterungsmethode CetToken erstellen?

War es hilfreich?

Lösung

Extension methods are just syntatic sugar for static methods. So what you really need is the ability to mock the static method here. Unfortunately this is not possible in Rhino Mocks.

See the following StackOverflow thread for more details

To mock a static method you need a mocking framework which actually uses the CLR profiler to intercept method calls. As the thread mentions TypeMock should be able to do this.

Andere Tipps

It should be possible by creating Stub for the extension methods.

Extension methods in Mono 2.4 and RhinoMocks 3.5

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