Skip to content

Instantly share code, notes, and snippets.

@starteleport
Created January 31, 2013 15:21
Show Gist options
  • Save starteleport/4683612 to your computer and use it in GitHub Desktop.
Save starteleport/4683612 to your computer and use it in GitHub Desktop.
Unable to map RecoveryTicket to RecoveryRecord, and backwards
[TestClass]
public class ForGitHub
{
#region Types
public class RecoveryRecord
{
public string Token { get; set; }
}
[MapField("Token", "TokenData.Token")]
public class RecoveryTicket
{
private readonly RecoveryTokenData _tokenData;
#region Ctors
public static RecoveryTicket Create(string token)
{
return new RecoveryTicket(token);
}
protected RecoveryTicket()
{
}
protected RecoveryTicket(string token)
{
_tokenData = RecoveryTokenData.Create(token);
}
#endregion
[MapField(Storage = "_tokenData")]
public RecoveryTokenData TokenData
{
get { return _tokenData; }
}
}
public class RecoveryTokenData
{
#region Ctors
public static RecoveryTokenData Create(string token)
{
return new RecoveryTokenData(token);
}
protected RecoveryTokenData()
{
}
protected RecoveryTokenData(string token)
{
_token = token;
}
#endregion
private readonly string _token;
[MapField(Storage = "_token")]
public string Token
{
get { return _token; }
}
}
#endregion
[TestMethod]
public void TestMapping()
{
RecoveryTicket rt = RecoveryTicket.Create("token");
RecoveryRecord rr;
//Act
rr = Map.GetObjectMapper<RecoveryTicket, RecoveryRecord>()(rt);
//Assert
Assert.IsNotNull(rr.Token);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment