hallo,
ich entsuldige mich für mein vielleicht simple Frage.
hier ist mein Testvorgang. ich weiss es nicht mehr es fehlschlägt. das Prinzip ist gleich wie in Beginning Mocking With Moq 3 – Part 1:
public interface IMyInterface
{
int DoSomething(string row);
}
public class Foo
{
private IMyInterface myInterface;
public Foo(IMyInterface myinterface)
{
this.myInterface= myinterface;
}
public int CallInterfaceMethod(string row)
{
return myInterface.DoSomething( row);
}
}
[TestClass]
public class FileSearchTestClass
{
private Mock<IMyInterface> mockMyInterface;
private Foo foo;
[TestInitialize]
public void init()
{
mockMyInterface = new Mock<IMyInterface>();
foo = new Foo(mockMyInterface.Object );
}
[TestMethod]
public void It_Should_Call_Search_Once()
{
string tempRow = "Atest";
foo.CallInterfaceMethod(tempRow);
mockMyInterface.Verify(m => m.DoSomething(tempRow), Times.Exactly(1));
}
}
Danke für die Hinweise.
Gruss
Marek
Hallo,
was bekommst Du ueberhaupt fuer eine Fehlermeldung?
Was ist den "tempRow" fuer eine Variable?
Gruss,
DaMoe
tempRow ist string, Meinen Beteag habe ich auch updated.
die Fehler Meldung:> Fehlermeldung:
Expected invocation on the mock exactly 1 times, but was 0 times: m => m.DoSomething(rempRow)
No setups configured.
es ist erledigt.
ich habe blöderweise verschiedene Parammeter übergeben gehabt. wie folgt:
newFileSearch.ExistMatches("Atest");
mockSearcher.Verify(m => m.ExistMatches("test"), Times.Exactly(1));
danke trotzdem