public void ShouldGetDefaultValueForReferenceType() { // Arrange Person person = new Person(); // Act var defaultValue = person.GetType().GetDefaultValue(); // Assert defaultValue.Should().Be(default(Person)); }
public void ShouldGetHashCodeOf3Values() { // Arrange Person person1 = new Person{ Name = "Lorem"}; Person person2 = new Person{ Name = "Ipsum"}; Person person3 = new Person{ Name = "Dolor"}; // Act var hashCode1 = HashCodeHelper.GetHashCode(person1, person2, person3); var hashCode2 = HashCodeHelper.GetHashCode(person1, person2, person3); // Assert hashCode1.Should().Be(hashCode2); }
public void ShouldGetHashCodeOfArray() { // Arrange Person person1 = new Person { Name = "Lorem" }; Person person2 = new Person { Name = "Ipsum" }; Person person3 = new Person { Name = "Dolor" }; Person person4 = new Person { Name = "Dolor" }; Person[] listOfPersons = new List<Person> { person1, person2, person3 }.ToArray(); Person[] listOfPersons2 = new List<Person> { person1, person2, person4 }.ToArray(); // Act var hashCode1 = HashCodeHelper.GetHashCode(listOfPersons); var hashCode2 = HashCodeHelper.GetHashCode(listOfPersons); var hashCode3 = HashCodeHelper.GetHashCode(listOfPersons2); // Assert hashCode1.Should().Be(hashCode2); hashCode2.Should().NotBe(hashCode3); }