Exemplo n.º 1
0
        public void CompareToShouldReturnNegativeValueWhenLeftHappensBeforeRight()
        {
            Stamp s1 = new Stamp();
            Stamp s2 = s1.Event();

            s1.CompareTo(s2).Should().BeLessThan(0);
        }
Exemplo n.º 2
0
        public void CompareToShouldReturnPositiveValueWhenRightHappensBeforeLeft()
        {
            Stamp s1 = new Stamp();
            Stamp s2 = s1.Event();

            s2.CompareTo(s1).Should().BeGreaterThan(0);
        }
Exemplo n.º 3
0
        public void EquivalentShouldReturnFalseWhenOneStampDominatesTheOther()
        {
            Stamp a = ((1, 0), (0, 1, 0));
            Stamp b = a.Event();

            a.Equivalent(b).Should().BeFalse();
        }
Exemplo n.º 4
0
        public void LeqShouldReturnFalseWhenComparingInflatedStampAndOriginalStamp()
        {
            // Arrange
            Stamp s1 = new Stamp();

            // Act
            Stamp s2 = s1.Event();

            // Assert
            s2.Leq(s1).Should().BeFalse();
        }
Exemplo n.º 5
0
        public void LeqShouldReturnTrueWhenComparingOriginalStampAndInflatedStamp()
        {
            // Arrange
            Stamp s1 = new Stamp();

            // Act
            Stamp s2 = s1.Event();

            // Assert
            s1.Leq(s2).Should().BeTrue();
        }
Exemplo n.º 6
0
        public void SendShouldReturnInflatedStampAsReturnValue()
        {
            // Arrange
            Stamp s = new Stamp();

            // Act
            Stamp _;
            Stamp returnValue = s.Send(out _);

            // Assert
            returnValue.Should().Be(s.Event());
        }
Exemplo n.º 7
0
        public void Itc2008Example()
        {
            // Start with seed stamp
            Stamp seed = new Stamp();

            seed.Should().Be(new Stamp(1, 0));

            // Fork seed stamp to create stamps for process A and B
            (Stamp a1, Stamp b1) = seed.Fork();
            a1.Should().Be(new Stamp(new Id.Node(1, 0), 0));
            b1.Should().Be(new Stamp(new Id.Node(0, 1), 0));

            // Process A suffers an event
            Stamp a2 = a1.Event();

            a2.Should().Be(new Stamp(new Id.Node(1, 0), new Event.Node(0, 1, 0)));

            // Process A forks to create stamp for new process C (dynamic number of participants)
            (Stamp a3, Stamp c1) = a2.Fork();
            a3.Should().Be(new Stamp(new Id.Node(new Id.Node(1, 0), 0), new Event.Node(0, 1, 0)));
            c1.Should().Be(new Stamp(new Id.Node(new Id.Node(0, 1), 0), new Event.Node(0, 1, 0)));

            // Process A suffers an event
            Stamp a4 = a3.Event();

            a4.Should().Be(new Stamp(new Id.Node(new Id.Node(1, 0), 0), new Event.Node(0, new Event.Node(1, 1, 0), 0)));

            // Process B suffers an event
            Stamp b2 = b1.Event();

            b2.Should().Be(new Stamp(new Id.Node(0, 1), new Event.Node(0, 0, 1)));

            // Process B suffers an event
            Stamp b3 = b2.Event();

            b3.Should().Be(new Stamp(new Id.Node(0, 1), new Event.Node(0, 0, 2)));

            // Process B and C synchronize (join and fork)
            (Stamp c3, Stamp b4) = b3.Sync(c1);
            c3.Should().Be(new Stamp(new Id.Node(new Id.Node(0, 1), 0), new Event.Node(1, 0, 1)));
            b4.Should().Be(new Stamp(new Id.Node(0, 1), new Event.Node(1, 0, 1)));

            // Process C retires and joins with process A
            Stamp a5 = a4.Join(c3);

            a5.Should().Be(new Stamp(new Id.Node(1, 0), new Event.Node(1, new Event.Node(0, 1, 0), 1)));

            // Process A suffers an event (inflates and simplifies to single integer event)
            Stamp a6 = a5.Event();

            a6.Should().Be(new Stamp(new Id.Node(1, 0), 2));
        }
Exemplo n.º 8
0
 

 public Stamp Increment() 

 {
     
 stamp = stamp.Event(); 
            return(CurrentStamp); 

 }
Exemplo n.º 9
0
 public Stamp Increment()
 {
     _s = _s.Event();
     return(CurrentStamp);
 }