Created
February 20, 2011 17:32
-
-
Save forki/836131 to your computer and use it in GitHub Desktop.
Automatic AutoMapper tests
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
public abstract class when_mapping_to_another_type_and_back<T, S> | |
{ | |
protected static T Model; | |
protected static T Mapped; | |
Because of = () => Mapped = Model.MapTo<S>().MapTo<T>(); | |
protected static void VerifyAllProperties() | |
{ | |
foreach (var property in typeof (T).GetProperties()) | |
{ | |
var modelProperty = property.GetValue(Model, null); | |
var mappedProperty = property.GetValue(Mapped, null); | |
modelProperty.ShouldEqual(mappedProperty); | |
} | |
} | |
} | |
public class when_mapping_AcqRequestLineViewModel_to_AcqRequestLine : | |
when_mapping_to_another_type_and_back<AcqRequestLineViewModel, AcqRequestLine> | |
{ | |
Establish context = | |
() => Model = | |
new AcqRequestLineViewModel | |
{ | |
Cost_Centre = "KST", | |
Cost_Unit = "KTR" | |
}; | |
It should_equal_the_original_model = VerifyAllProperties; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment