public void TestEquals() { var createOptions = new MongoGridFSCreateOptions { ChunkSize = 123 }; var a = new MongoGridFSFileInfo(gridFS, "f", createOptions); var b = new MongoGridFSFileInfo(gridFS, "f", createOptions); var c = new MongoGridFSFileInfo(gridFS, "g", createOptions); var n = (MongoCredentials) null; Assert.IsTrue(object.Equals(a, b)); Assert.IsFalse(object.Equals(a, c)); Assert.IsFalse(a.Equals(n)); Assert.IsFalse(a.Equals(null)); Assert.IsTrue(a == b); Assert.IsFalse(a == c); Assert.IsFalse(a == null); Assert.IsFalse(null == a); Assert.IsTrue(n == null); Assert.IsTrue(null == n); Assert.IsFalse(a != b); Assert.IsTrue(a != c); Assert.IsTrue(a != null); Assert.IsTrue(null != a); Assert.IsFalse(n != null); Assert.IsFalse(null != n); }
public void TestEquals() { var createOptions = new MongoGridFSCreateOptions { ChunkSize = 123 }; var a1 = new MongoGridFSFileInfo(_gridFS, "f", createOptions); var a2 = new MongoGridFSFileInfo(_gridFS, "f", createOptions); var a3 = a2; var b = new MongoGridFSFileInfo(_gridFS, "g", createOptions); var null1 = (MongoGridFSFileInfo)null; var null2 = (MongoGridFSFileInfo)null; Assert.AreNotSame(a1, a2); Assert.AreSame(a2, a3); Assert.IsTrue(a1.Equals((object)a2)); Assert.IsFalse(a1.Equals((object)null)); Assert.IsFalse(a1.Equals((object)"x")); Assert.IsTrue(a1 == a2); Assert.IsTrue(a2 == a3); Assert.IsFalse(a1 == b); Assert.IsFalse(a1 == null1); Assert.IsFalse(null1 == a1); Assert.IsTrue(null1 == null2); Assert.IsFalse(a1 != a2); Assert.IsFalse(a2 != a3); Assert.IsTrue(a1 != b); Assert.IsTrue(a1 != null1); Assert.IsTrue(null1 != a1); Assert.IsFalse(null1 != null2); Assert.AreEqual(a1.GetHashCode(), a2.GetHashCode()); }
public void TestEquals() { var settings = new MongoGridFSSettings(); var createOptions = new MongoGridFSCreateOptions { ChunkSize = 123 }; var a1 = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "f", createOptions); var a2 = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "f", createOptions); var a3 = a2; var b = new MongoGridFSFileInfo(_server, _server.Primary, _database.Name, settings, "g", createOptions); var null1 = (MongoGridFSFileInfo)null; var null2 = (MongoGridFSFileInfo)null; Assert.NotSame(a1, a2); Assert.Same(a2, a3); Assert.True(a1.Equals((object)a2)); Assert.False(a1.Equals((object)null)); Assert.False(a1.Equals((object)"x")); Assert.True(a1 == a2); Assert.True(a2 == a3); Assert.False(a1 == b); Assert.False(a1 == null1); Assert.False(null1 == a1); Assert.True(null1 == null2); Assert.False(a1 != a2); Assert.False(a2 != a3); Assert.True(a1 != b); Assert.True(a1 != null1); Assert.True(null1 != a1); Assert.False(null1 != null2); Assert.Equal(a1.GetHashCode(), a2.GetHashCode()); }