Reputation:
I have a class:
public class BankingTransfer : IBankingTransfer
{
public decimal GetTrustAccountBalance(string Id, string Pin)
{
throw new NotImplementedException();
}
Now I want to do a xunit test on it. But not sure how to test a dummy return value?
My code:
public class GetTrustAccountBalanceUnitTest
{
[Theory]
[InlineData("1234")]
[InlineData("1234")]
public void GetTrustAccountBalance_Should_Return_A_Value(string expectedId,string expectedPin)
{
// ARRANGE
var bankingTransferMock =new Mock<IBankingTransfer>();
// ACT
bankingTransferMock.Setup(x=>x.GetTrustAccountBalance(expectedId,expectedPin)).Returns()
// ASSURE
}
}
Upvotes: 2
Views: 6331
Reputation: 3681
Just put a value inside the returns value like this:
bankingTransferMock.Setup(x=>x.GetTrustAccountBalance(expectedId,expectedPin)).Returns(1);
However, I think that you have misunderstood how to test the class that you have displayed. You shouldn't mock the class that you are trying to test. Going by the test name you probably want something more along these lines where you are just calling the method and seeing what is returned.
var bankingTransfer = new BankingTransfer();
Assert.True(bankingTransfer.GetTrustAccountBalance("", "") > 0);
Upvotes: 2