Created
December 28, 2010 20:37
-
-
Save juanplopes/757680 to your computer and use it in GitHub Desktop.
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
[Test] | |
public void ShouldServeAsNonGenericIEqualityComparer() | |
{ | |
Sample1 obj1 = new Sample1(); | |
EqualityHelper<Sample1> helper = new EqualityHelper<Sample1>(); | |
helper.Add(x => x.IntProp); | |
helper.Add(x => x.StringProp); | |
var hash = new Hashtable(helper); | |
hash.Add(new Sample1() { IntProp = 2, StringProp = "asd" }, "doesn't matter"); | |
hash.ContainsKey(new Sample1() { IntProp = 2, StringProp = "asd" }).Should().Be.True(); | |
hash.ContainsKey(new Sample1() { IntProp = 3, StringProp = "asd" }).Should().Be.False(); | |
} | |
[Test] | |
public void ShouldServeAsGenericIEqualityComparer() | |
{ | |
Sample1 obj1 = new Sample1(); | |
EqualityHelper<Sample1> helper = new EqualityHelper<Sample1>(); | |
helper.Add(x => x.IntProp); | |
helper.Add(x => x.StringProp); | |
var hash = new Dictionary<Sample1, string>(helper); | |
hash.Add(new Sample1() { IntProp = 2, StringProp = "asd" }, "doesn't matter"); | |
hash.ContainsKey(new Sample1() { IntProp = 2, StringProp = "asd" }).Should().Be.True(); | |
hash.ContainsKey(new Sample1() { IntProp = 3, StringProp = "asd" }).Should().Be.False(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment