public void Equals_should_return_false_if_obj_is_null() { var subject = new CompressorConfiguration(CompressorType.Noop); var result = subject.Equals(null); result.Should().BeFalse(); }
public void Equals_should_return_false_if_obj_is_wrong_type() { var subject = new CompressorConfiguration(CompressorType.Noop); var obj = new object(); var result = subject.Equals(new object()); var hashCode1 = subject.GetHashCode(); var hashCode2 = obj.GetHashCode(); result.Should().BeFalse(); hashCode2.Should().NotBe(hashCode1); }
public void Equals_should_return_true_if_all_fields_are_equal(CompressorType type) { var subject1 = new CompressorConfiguration(type); var subject2 = new CompressorConfiguration(type); subject1.Properties.Add("x", 1); subject2.Properties.Add("x", 1); var result = subject1.Equals(subject2); var hashCode1 = subject1.GetHashCode(); var hashCode2 = subject2.GetHashCode(); result.Should().BeTrue(); hashCode2.Should().Be(hashCode1); }
public void Equals_should_return_false_if_any_field_is_not_equal(string fieldName) { var type = CompressorType.Snappy; var key = "x"; var subject1 = new CompressorConfiguration(type); subject1.Properties.Add(key, 1); switch (fieldName) { case "Properties": key = "y"; break; case "Type": type = CompressorType.Zlib; break; } var subject2 = new CompressorConfiguration(type); subject2.Properties.Add(key, 1); var result = subject1.Equals(subject2); var hashCode1 = subject1.GetHashCode(); var hashCode2 = subject2.GetHashCode(); result.Should().BeFalse(); hashCode2.Should().NotBe(hashCode1); }