public void TestEquality2() { var articleMetaData1 = new ArticleMetadata() { Title = "Some Title", Slug = "some-slug", PublishDate = new System.DateTime(2019, 6, 1), Description = "some description" }; var articleMetaData2 = new ArticleMetadata() { Title = "Some Title", Slug = "some-slug", PublishDate = new System.DateTime(2019, 6, 1), Description = "some description" }; Assert.AreEqual(articleMetaData1, articleMetaData2); Assert.IsTrue(articleMetaData1.Equals(articleMetaData2)); Assert.IsTrue(articleMetaData1 == articleMetaData2); Assert.IsFalse(articleMetaData1 != articleMetaData2); Assert.IsTrue(articleMetaData1 <= articleMetaData2); Assert.IsTrue(articleMetaData1 >= articleMetaData2); Assert.AreEqual(articleMetaData1.GetHashCode(), articleMetaData2.GetHashCode()); }
public void TestEqualityBothEmpty() { var articleMetaData1 = new ArticleMetadata(); var articleMetaData2 = new ArticleMetadata(); Assert.AreEqual(articleMetaData1, articleMetaData2); Assert.IsTrue(articleMetaData1.Equals(articleMetaData2)); Assert.IsTrue(articleMetaData1 == articleMetaData2); Assert.IsFalse(articleMetaData1 != articleMetaData2); Assert.IsTrue(articleMetaData1 <= articleMetaData2); Assert.IsTrue(articleMetaData1 >= articleMetaData2); Assert.AreEqual(articleMetaData1.GetHashCode(), articleMetaData2.GetHashCode()); }
public void TestInequality() { var articleMetaData1 = new ArticleMetadata() { Title = "Some Title", Slug = "some-slug", PublishDate = new System.DateTime(2019, 6, 1) }; var articleMetaData2 = new ArticleMetadata() { Title = "Some Title", Slug = "some-slug2", PublishDate = new System.DateTime(2019, 6, 1) }; Assert.AreNotEqual(articleMetaData1, articleMetaData2); Assert.IsFalse(articleMetaData1.Equals(articleMetaData2)); Assert.IsFalse(articleMetaData1 == articleMetaData2); Assert.IsTrue(articleMetaData1 != articleMetaData2); }