MOQ OVIDE PROVETUP OUTUP?C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 MOQ OVIDE PROVETUP OUTUP?

Post by Anonymous »

Hallo, ich versuche, ein Mock der Methode einer Klasse mit zwei möglichen Eingaben festzulegen. Wenn ich die Ausgabe nur über die letzte Einrichtung überprüfe, die die erwartete Ausgabe erwartete. Der erste tat es nicht. Jede Hilfe wird sehr geschätzt. < /P>

Code: Select all

[Test]
public void ClimbOnceTwoNeighbour_Sample()
{
stateConverter = new Mock();

solution = new Mock();
state = new Mock();

var neightbourSolution1 = new Mock();
var neighbourState1 = new Mock();
var neightbourSolution2 = new Mock();
var neighbourState2 = new Mock();

stateConverter.Setup(x => x.FromSolution(neightbourSolution1.Object, It.IsAny())).Returns(neighbourState1.Object);
stateConverter.Setup(x => x.FromSolution(neightbourSolution2.Object, It.IsAny())).Returns(neighbourState2.Object);

var state1 = stateConverter.Object.FromSolution(neightbourSolution1.Object, state.Object);//return null ????
var state2 = stateConverter.Object.FromSolution(neightbourSolution2.Object, state.Object);//return neighbourState2.Object)

Assert.AreEqual(neighbourState2.Object, state2);//pass test here
Assert.AreEqual(neighbourState1.Object, state1);//fail here due to null is returned from previous statement

}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post