You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I have tried to mock and class and set up it as followed. What ever I tried only one assert return is true. I have tired to replace Input with String and Output class with int and its works fine. Any suggestion please? Thank you very much
[TestFixture]
class TestSample
{
[Test]
public void Test1()
{
Mock<SampleClass> mockObject = new Mock<SampleClass>();
var mockInput1 = new Mock<InputClass>();
var mockInput2 = new Mock<InputClass>();
var mockOutPut1 = new Mock<OutputClass>();
var mockOutPut2 = new Mock<OutputClass>();
mockObject.Setup(x => x.Get(mockInput1.Object)).Returns(mockOutPut1.Object);
mockObject.Setup(x => x.Get(mockInput2.Object)).Returns(mockOutPut2.Object);
var returned = mockObject.Object.Get(mockInput1.Object);
Assert.AreEqual(mockOutPut1, returned);
returned = mockObject.Object.Get(mockInput2.Object);
Assert.AreEqual(mockOutPut2, returned);
returned = mockObject.Object.Get(mockInput1.Object);
Assert.AreEqual(mockOutPut1, returned);
}
}
public class SampleClass
{
public virtual OutputClass Get(InputClass a)
{
return null;
}
}
public class InputClass {}
public class OutputClass {}
The text was updated successfully, but these errors were encountered:
Hi I have tried to mock and class and set up it as followed. What ever I tried only one assert return is true. I have tired to replace Input with String and Output class with int and its works fine. Any suggestion please? Thank you very much
The text was updated successfully, but these errors were encountered: