Created
July 5, 2012 18:55
-
-
Save diegocaxito/3055695 to your computer and use it in GitHub Desktop.
DTO Assert
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
[TestClass] | |
public class Test{ | |
public void TestAssert(){ | |
//.... | |
AssertUtil.AssertProperties(myExpectedResult, myActualResult); | |
} | |
} | |
public static class AssertUtil | |
{ | |
public static void AssertProperties<T>(T expected, T actual) | |
{ | |
foreach (var property in typeof(T).GetProperties()) | |
Assert.AreEqual(property.GetValue(expected, null).FromNullToString(), property.GetValue(actual, null).FromNullToString(), property.Name); | |
} | |
} | |
internal static class ConvertNull | |
{ | |
public static string FromNullToString(this object value) | |
{ | |
return value != null ? value.ToString() : string.Empty; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment