Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a POCO class
C#
public class FundsTransferInfo
{
  public string SiteId { get; set; }
  public string UserId { get; set; }
  public string Password { get; set; }
  public string TelephoneId { get; set; }
  public string BillToNumber { get; set; }
  public Decimal AmountToBeTransferdFromTrustToDebit { get; set; }
}

And I have another class
C#
public class TrustAccountTransfer : ITrustAccountTransfer
{
  private readonly FundsTransferInfo _fundsTransferInfo;
  public TrustAccountTransfer(FundsTransferInfo fundsTransferInfo)
  {
      this._fundsTransferInfo = fundsTransferInfo;
  }

In my unit test, I have
C#
var fundsInfoMock = new Mock<FundsTransferInfo>();
var fundsInfo = fundsInfoMock.Object;
var transfer = new AccountTransfer(fundsInfo);

My question is how to set the POCO class FundsTransferInfo?

Originally I used
C#
fundsInfoMock.SetupGet(x => x.Password).Returns("password");
etcs.
However it will be dependent on the hard code string. I want the properties can be any string.....
Posted
Comments
Tomas Takac 19-Nov-15 15:25pm    
You don't need to mock it! It's just a property bag, no functionality to mock. Use it directly.
[no name] 19-Nov-15 15:32pm    
I understand it. But if I set it as a different hard code string, the test result will be upon it. Can we avoid it? Or just enumerate all possibilities?
nportelli 19-Nov-15 15:43pm    
Create a different one for each test. They shouldn't be shared.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900