Example #1
0
        public void ReverseOfAddParticipantIsRemoveParticipant()
        {
            var context = A.Fake<WaveletOperationContext>();
            var rop = new RemoveParticipantOperation(context, Creator);
            var aop = new AddParticipantOperation(context, Creator, 0);
            WaveletData wavelet = CreateWaveletData();

            IList<WaveletOperation> reverse = aop.ApplyAndReturnReverse(wavelet);
            WaveletOperation result = reverse[0];

            reverse.Should().HaveCount(1);
            result.Should().BeOfType<RemoveParticipantOperation>();
            result.IsWorthyOfAttribution().Should().BeTrue();
            result.As<RemoveParticipantOperation>().ParticipantId.Should().Be(Creator);
        }
 public void AddParticipantTest()
 {
     var op = new AddParticipantOperation(A.Fake<WaveletOperationContext>(), _participantId);
     
 }
Example #3
0
 /// <summary>
 ///     Checks to see if a participant is being removed by one operation and added
 ///     by another concurrent operation. In such a situation, at least one of the
 ///     operations is invalid.
 /// </summary>
 /// <param name="removeOperation">The operation to remove a participant.</param>
 /// <param name="addOperation">The operation to add a participant.</param>
 /// <exception cref="TransformException">
 ///     TransformException if the same participant is being concurrently added and
 ///     removed.
 /// </exception>
 private static void CheckParticipantRemovalAndAddition(RemoveParticipantOperation removeOperation,
     AddParticipantOperation addOperation)
 {
     if (removeOperation.ParticipantId.Equals(addOperation.ParticipantId))
         throw new TransformException("Transform error involving participant: " +
                                      removeOperation.ParticipantId.Address);
 }
Example #4
0
        public void CannotAddSameParticipantTwice()
        {
            WaveletData wavelet = CreateWaveletData();
            var context = A.Fake<WaveletOperationContext>();
            var first = new AddParticipantOperation(context, Creator, 0);
            var second = new AddParticipantOperation(context, Creator, 0);

            first.Apply(wavelet);
            var ex = Assert.Throws<OperationException>(() => second.Apply(wavelet));

            ex.Message.Should().Be("Attempt to add a duplicate participant");
        }