public void Should_change_its_hashcode_everytime_the_list_is_updated() { var list = new ListByValue <Card>() { Card.Parse("QC"), Card.Parse("TS") }; var previousHashcode = list.GetHashCode(); list.Add(Card.Parse("3H")); // ---update the list --- var currentHashcode = list.GetHashCode(); Check.That(currentHashcode).IsNotEqualTo(previousHashcode); previousHashcode = list.GetHashCode(); list.Remove(Card.Parse("QC")); // ---update the list --- currentHashcode = list.GetHashCode(); Check.That(currentHashcode).IsNotEqualTo(previousHashcode); previousHashcode = list.GetHashCode(); list.Clear(); // ---update the list --- currentHashcode = list.GetHashCode(); Check.That(currentHashcode).IsNotEqualTo(previousHashcode); previousHashcode = list.GetHashCode(); list.Insert(0, Card.Parse("AS")); // ---update the list --- currentHashcode = list.GetHashCode(); Check.That(currentHashcode).IsNotEqualTo(previousHashcode); previousHashcode = list.GetHashCode(); list[0] = Card.Parse("QH"); currentHashcode = list.GetHashCode(); Check.That(currentHashcode).IsNotEqualTo(previousHashcode); previousHashcode = list.GetHashCode(); list.RemoveAt(0); currentHashcode = list.GetHashCode(); Check.That(currentHashcode).IsNotEqualTo(previousHashcode); }
public void Should_change_its_hashcode_everytime_the_list_is_updated() { var list = new ListByValue <Card>() { Card.Parse("QC"), Card.Parse("TS") }; var firstHashCode = list.GetHashCode(); list.Add(Card.Parse("3H")); // ---update the list --- var afterAddHash = list.GetHashCode(); Check.That(firstHashCode).IsNotEqualTo(afterAddHash); list.Remove(Card.Parse("QC")); // ---update the list --- var afterRemoveHash = list.GetHashCode(); Check.That(afterRemoveHash).IsNotEqualTo(afterAddHash); list.Clear(); // ---update the list --- var afterClearHash = list.GetHashCode(); Check.That(afterClearHash).IsNotEqualTo(afterRemoveHash); Check.That(list.Count).IsZero(); list.Insert(0, Card.Parse("AS")); // ---update the list --- Check.That(list.Count).IsEqualTo(1); var afterInsertHash = list.GetHashCode(); Check.That(afterInsertHash).IsNotEqualTo(afterClearHash); list[0] = Card.Parse("QH"); var afterIndexerHash = list.GetHashCode(); Check.That(afterIndexerHash).IsNotEqualTo(afterInsertHash); list.RemoveAt(0); var afterRemoveAtHash = list.GetHashCode(); Check.That(afterRemoveAtHash).IsNotEqualTo(afterIndexerHash); }