Skip to content

Instantly share code, notes, and snippets.

@CalvinRodo
Created May 14, 2012 18:57
Show Gist options
  • Save CalvinRodo/2695702 to your computer and use it in GitHub Desktop.
Save CalvinRodo/2695702 to your computer and use it in GitHub Desktop.
Mapper Example.
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