Created
May 14, 2012 18:57
-
-
Save CalvinRodo/2695702 to your computer and use it in GitHub Desktop.
Mapper Example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Foo | |
<Convertible()> | |
Public Property String Baz | |
<Convertible()> | |
Public Propery String Faz | |
End Class | |
Class Bar | |
<ErrorMessage(“Error Converting BAZ”)> | |
Public Property Date Baz | |
<ErrorMessage(“Error Converting FAZ”)> | |
Public Property Int Faz | |
End Class | |
<TestMethod()> | |
Public Sub Test() | |
Dim draft as New Foo() With { .Baz = "2001/01/01", .Faz = "100" } | |
Dim actual as New Actual() | |
Dim mapper as New Mapper() | |
Dim errors as List(Of String) = mapper.Convert(of Foo, Bar)(ref Foo, Bar) | |
Assert.AreEqual(0, errors.Count()) | |
Assert.AreEqual(Date.Parse("2001/01/01"), actual.Baz) | |
Assert.AreEqual(100, actual.Faz) | |
End Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment