public void TwoInstancesAreNotEqualIfMarkedForSendingDiffers() { // given var target = new BeaconCacheRecord(1234L, "abc"); var other = new BeaconCacheRecord(1234L, "abc"); other.MarkForSending(); // then Assert.That(target.Equals(other), Is.False); }
public void NotEqualInstancesHaveDifferentHashCode() { // given var target = new BeaconCacheRecord(1234L, "abc"); var otherOne = new BeaconCacheRecord(4321L, "abc"); var otherTwo = new BeaconCacheRecord(1234L, "abcd"); var otherThree = new BeaconCacheRecord(1234L, "abcd"); otherThree.MarkForSending(); // then Assert.That(target.GetHashCode(), Is.Not.EqualTo(otherOne.GetHashCode())); Assert.That(target.GetHashCode(), Is.Not.EqualTo(otherTwo.GetHashCode())); Assert.That(target.GetHashCode(), Is.Not.EqualTo(otherThree.GetHashCode())); }
public void TwoEqualInstancesHaveSameHashCode() { // given var target = new BeaconCacheRecord(1234L, "abc"); var other = new BeaconCacheRecord(1234L, "abc"); // then Assert.That(target.GetHashCode(), Is.EqualTo(other.GetHashCode())); // and when marking both for sending target.MarkForSending(); other.MarkForSending(); // then Assert.That(target.GetHashCode(), Is.EqualTo(other.GetHashCode())); }
public void TwoInstancesAreEqualIfFieldsAreEqual() { // given var target = new BeaconCacheRecord(1234L, "abc"); var other = new BeaconCacheRecord(1234L, "abc"); // then Assert.That(target.Equals(other), Is.True); // and when setting send flag target.MarkForSending(); other.MarkForSending(); // then Assert.That(target.Equals(other), Is.True); }
public void MarkForSending() { // given var target = new BeaconCacheRecord(0L, "abc"); // then a newly created record is not marked for sending Assert.That(target.IsMarkedForSending, Is.False); // and when explicitly marked for sending target.MarkForSending(); // then Assert.That(target.IsMarkedForSending, Is.True); // and when the sending mark is removed target.UnsetSending(); // then Assert.That(target.IsMarkedForSending, Is.False); }