public void ShouldBeEqualWithSameReference() { var val1 = new DummyValueType(); // ReSharper disable once EqualExpressionComparison val1.Equals(val1).Should().BeTrue(); }
public void ShouldNotBeEqualToNull() { var val1 = new DummyValueType { Id = 1, Name = "Luis" }; val1.Equals(null).Should().BeFalse(); }
public void ShouldBeEqualSameReferenceWithNonNullValues() { var val1 = new DummyValueType { Id = 1, Name = "Luis" }; // ReSharper disable once EqualExpressionComparison val1.Equals(val1).Should().BeTrue(); }
public void Equality_DifferentReferences_SameValues_True() { DummyValueType valueObject1 = new DummyValueType { Id = 1, Name = "Luis" }; DummyValueType valueObject2 = new DummyValueType { Id = 1, Name = "Luis" }; Assert.That(valueObject1, Is.Not.SameAs(valueObject2)); Assert.That(valueObject1, Is.EqualTo(valueObject2)); Assert.That(valueObject1.Equals(valueObject2)); Assert.That(valueObject1 == valueObject2); valueObject2.Name = "Billy"; Assert.That(valueObject1 != valueObject2); }
public void ShouldBeEqualWithDifferentReferences() { var val1 = new DummyValueType { Id = 1, Name = "Luis" }; var val2 = new DummyValueType { Id = 1, Name = "Luis" }; val1.Equals(val2).Should().BeTrue(); }
public void ShouldNotBeEqualWithDifferentReferencesAndDifferentIds() { var val1 = new DummyValueType { Id = 1, Name = "Luis" }; var val2 = new DummyValueType { Id = 10, Name = "Luis" }; val2.Equals(val1).Should().BeFalse(); }
public void Equality_DifferentReferences_SameValues_True() { var valueObj1 = new DummyValueType { Id = 1, Name = "Luis" }; var valueObj2 = new DummyValueType { Id = 1, Name = "Luis" }; valueObj1.Should().NotBeSameAs(valueObj2); valueObj1.Equals(valueObj2).Should().BeTrue(); (valueObj1 == valueObj2).Should().BeTrue(); valueObj2.Name = "Billy"; (valueObj1 == valueObj2).Should().BeFalse(); }
public void Equality_DifferentReferences_SameValues_True() { var valueObject1 = new DummyValueType { Id = 1, Name = "Luis" }; var valueObject2 = new DummyValueType { Id = 1, Name = "Luis" }; Assert.That(valueObject1, Is.Not.SameAs(valueObject2)); Assert.That(valueObject1, Is.EqualTo(valueObject2)); Assert.That(valueObject1.Equals(valueObject2)); Assert.That(valueObject1 == valueObject2); valueObject2.Name = "Billy"; Assert.That(valueObject1 != valueObject2); }