1: [Test]
2: public void TestValueComparison()
3: {
4: int a = 1;
5: int b = 1;
6: Assert.IsTrue( a == b );
7: Assert.IsTrue( a.Equals( b ) );
8: Assert.IsFalse( Object.ReferenceEquals( a, b ) );
9: //Interned strings
10: string x = "test";
11: string y = "test";
12: Assert.IsTrue( x == y );
13: Assert.IsTrue( x.Equals( y ) );
14: Assert.IsTrue( Object.ReferenceEquals( x, y ) );
15: //Non-interned strings
16: string p = new string( 'a', 3 );
17: string q = new string( 'a', 3 );
18: Assert.IsTrue( p == q );
19: Assert.IsTrue( p.Equals( q ) );
20: Assert.IsFalse( Object.ReferenceEquals( p, q ) );
21: //Manually interning the strings
22: p = string.Intern( p );
23: q = string.Intern( q );
24: Assert.IsTrue( Object.ReferenceEquals( p, q ) );
25: }