Beispiel #1
0
        public void CompareTopologyVersion_should_return_zero_when_topologies_are_equal()
        {
            var processId = ObjectId.Empty;
            var counter   = 31L;

            var local          = new TopologyVersion(processId, counter);
            var serverResponse = local;

            TopologyVersion.CompareTopologyVersion(local, serverResponse).Should().Be(0);

            TopologyVersion.IsFresherThanOrEqualTo(local, serverResponse).Should().BeTrue();
            TopologyVersion.IsFresherThan(local, serverResponse).Should().BeFalse();

            TopologyVersion.IsStalerThanOrEqualTo(local, serverResponse).Should().BeTrue();
            TopologyVersion.IsStalerThan(local, serverResponse).Should().BeFalse();
        }
Beispiel #2
0
        public void CompareTopologyVersion_should_return_expected_when_processIds_are_equal_and_one_has_bigger_counter()
        {
            var processId1 = ObjectId.Empty;
            var processId2 = ObjectId.Empty;
            var counter    = 42L;

            var older = new TopologyVersion(processId1, counter);
            var newer = new TopologyVersion(processId2, counter + 1);

            TopologyVersion.CompareTopologyVersion(older, newer).Should().BeNegative();
            TopologyVersion.IsStalerThan(older, newer).Should().BeTrue();
            TopologyVersion.IsFresherThan(older, newer).Should().BeFalse();

            TopologyVersion.CompareTopologyVersion(newer, older).Should().BePositive();
            TopologyVersion.IsStalerThan(newer, older).Should().BeFalse();
            TopologyVersion.IsFresherThan(newer, older).Should().BeTrue();
        }
Beispiel #3
0
        public void CompareTopologyVersion_should_always_return_negative_if_any_comparand_is_null()
        {
            var processId = ObjectId.Empty;
            var counter   = 31L;

            TopologyVersion nullTopologyVersion    = null;
            TopologyVersion nonNullTopologyVersion = new TopologyVersion(processId, counter);

            TopologyVersion.CompareTopologyVersion(nullTopologyVersion, nonNullTopologyVersion).Should().BeNegative();
            TopologyVersion.IsStalerThan(nullTopologyVersion, nonNullTopologyVersion).Should().BeTrue();
            TopologyVersion.IsFresherThan(nullTopologyVersion, nonNullTopologyVersion).Should().BeFalse();

            TopologyVersion.CompareTopologyVersion(nonNullTopologyVersion, nullTopologyVersion).Should().BeNegative();
            TopologyVersion.IsStalerThan(nonNullTopologyVersion, nullTopologyVersion).Should().BeTrue();
            TopologyVersion.IsFresherThan(nonNullTopologyVersion, nullTopologyVersion).Should().BeFalse();

            TopologyVersion.CompareTopologyVersion(nullTopologyVersion, nullTopologyVersion).Should().BeNegative();
            TopologyVersion.IsStalerThan(nullTopologyVersion, nullTopologyVersion).Should().BeTrue();
            TopologyVersion.IsFresherThan(nullTopologyVersion, nullTopologyVersion).Should().BeFalse();
        }
Beispiel #4
0
        public void CompareTopologyVersion_should_always_return_negative_if_processIds_are_not_equal()
        {
            var processId1 = ObjectId.Empty;
            var processId2 = ObjectId.GenerateNewId();
            var counter    = 42L;

            var subject1       = new TopologyVersion(processId1, counter);
            var subject2       = new TopologyVersion(processId2, counter);
            var local          = subject1;
            var serverResponse = subject2;

            TopologyVersion.CompareTopologyVersion(local, serverResponse).Should().BeNegative();
            TopologyVersion.IsStalerThan(local, serverResponse).Should().BeTrue();
            TopologyVersion.IsFresherThan(local, serverResponse).Should().BeFalse();

            // changing the order should change the results
            local          = subject2;
            serverResponse = subject1;

            TopologyVersion.CompareTopologyVersion(local, serverResponse).Should().BeNegative();
            TopologyVersion.IsStalerThan(local, serverResponse).Should().BeTrue();
            TopologyVersion.IsFresherThan(local, serverResponse).Should().BeFalse();
        }