コード例 #1
0
        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);
        }
コード例 #2
0
        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()));
        }
コード例 #3
0
        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()));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }