public void CompareTo_1() { var brownde01 = new PlayerBlobObject { ID = "brownde01", Name = "Dee Brown" }; var brownde02 = new PlayerBlobObject { ID = "brownde02", Name = "Devin Brown" }; var brownde03 = new PlayerBlobObject { ID = "brownde03", Name = "Dee Brown" }; Assert.IsTrue(brownde01.CompareTo(brownde02) < 0); Assert.IsTrue(brownde02.CompareTo(brownde01) > 0); Assert.IsTrue(brownde01.CompareTo(brownde01) == 0); Assert.IsTrue(brownde01.CompareTo(brownde03) < 0); Assert.IsTrue(brownde02.CompareTo(brownde03) > 0); Assert.IsTrue(new[] { brownde01, brownde03, brownde02 }.SequenceEqual( new[] { brownde01, brownde02, brownde03 }.OrderBy(p => p))); }
public void Equals() { var player1 = new PlayerBlobObject { ID = "1", Name = "Test", FirstSeason = 2000, LastSeason = 2010, }; var player2 = new PlayerBlobObject { ID = "1", Name = "Test", FirstSeason = 2000, LastSeason = 2010, }; Assert.IsTrue(player1 != player2); Assert.IsTrue(player1.Equals(player2)); player2.Name = "Test Test"; Assert.IsFalse(player1.Equals(player2)); Assert.IsFalse(player2.Equals(player1)); player1.Name = "Test Test"; Assert.IsTrue(player1.Equals(player2)); Assert.IsTrue(player2.Equals(player1)); player2 = null; Assert.IsFalse(player1.Equals(player2)); }
public void CompareTo_2() { var player1 = new PlayerBlobObject { ID = "aa01", Name = "A A A" }; var player2 = new PlayerBlobObject { ID = "aab01", Name = "Ab A A" }; Assert.IsTrue(player1.CompareTo(player2) < 0); }