Beispiel #1
0
 protected override Task Because()
 {
     Stream = new OptimisticEventStream(BucketId, StreamId, Persistence, SystemTimeProvider);
     Stream.Add(new EventMessage()
     {
         Body = "body"
     });
     return(Stream.CommitChanges(Guid.NewGuid()));
 }
 protected override void Because()
 {
     Stream = new OptimisticEventStream(BucketId, StreamId, Persistence);
     Stream.Add(new EventMessage()
     {
         Body = "body"
     });
     Stream.CommitChanges(Guid.NewGuid());
 }
        protected override void Context()
        {
            _committed          = new[] { BuildCommitStub(1, 1, 1) };
            _discoveredOnCommit = new[] { BuildCommitStub(3, 2, 2) };

            A.CallTo(() => Persistence.Commit(A <CommitAttempt> ._)).Throws(new ConcurrencyException());
            A.CallTo(() => Persistence.GetFrom(BucketId, StreamId, StreamRevision, int.MaxValue)).Returns(_committed);
            A.CallTo(() => Persistence.GetFrom(BucketId, StreamId, StreamRevision + 1, int.MaxValue)).Returns(_discoveredOnCommit);

            Stream = new OptimisticEventStream(BucketId, StreamId, Persistence, StreamRevision, int.MaxValue);
            Stream.Add(_uncommitted);
        }
        protected override Task Context()
        {
            _committed          = new[] { BuildCommitStub(1, 1, 1) };
            _discoveredOnCommit = new[] { BuildCommitStub(3, 2, 2) };

            A.CallTo(() => Persistence.CommitAsync(A <CommitAttempt> ._, A <CancellationToken> ._)).Throws(new ConcurrencyException());
            A.CallTo(() => Persistence.GetFromAsync(BucketId, StreamId, StreamRevision, int.MaxValue)).Returns(_committed);
            A.CallTo(() => Persistence.GetFromAsync(BucketId, StreamId, StreamRevision + 1, int.MaxValue)).Returns(_discoveredOnCommit);

            Stream = new OptimisticEventStream(BucketId, StreamId, Persistence, StreamRevision, int.MaxValue, CancellationToken.None);
            Stream.Add(_uncommitted);
            return(Task.CompletedTask);
        }
Beispiel #5
0
        protected override void Context()
        {
            _committed          = new[] { BuildCommitStub(1, 1, 1) };
            _discoveredOnCommit = new[] { BuildCommitStub(3, 2, 2) };

            Persistence
            .Setup(x => x.Commit(It.IsAny <CommitAttempt>()))
            .Throws(new ConcurrencyException());
            Persistence
            .Setup(x => x.GetFrom(Bucket.Default, StreamId, StreamRevision, int.MaxValue))
            .Returns(_committed);
            Persistence
            .Setup(x => x.GetFrom(Bucket.Default, StreamId, StreamRevision + 1, int.MaxValue))
            .Returns(_discoveredOnCommit);

            Stream = new OptimisticEventStream(StreamId, Persistence.Object, StreamRevision, int.MaxValue);
            Stream.Add(_uncommitted);
        }
Beispiel #6
0
        protected override async Task Context()
        {
            _committed          = new[] { BuildCommitStub(1, 1, 1) };
            _discoveredOnCommit = new[] { BuildCommitStub(3, 2, 2) };

            //A.CallTo(() => Persistence.Commit(A<CommitAttempt>._)).Throws(new ConcurrencyException());
            //A.CallTo(() => Persistence.GetFrom(BucketId, StreamId, StreamRevision, int.MaxValue)).Returns(_committed.AsAsyncEnumerable());
            //A.CallTo(() => Persistence.GetFrom(BucketId, StreamId, StreamRevision + 1, int.MaxValue)).Returns(_discoveredOnCommit.AsAsyncEnumerable());

            Persistence
            .When(x => x.Commit(Arg.Any <CommitAttempt>()))
            .Do(x => { throw new ConcurrencyException(); });

            Persistence.GetFrom(BucketId, StreamId, StreamRevision, int.MaxValue).Returns(_committed.AsAsyncEnumerable());
            Persistence.GetFrom(BucketId, StreamId, StreamRevision + 1, int.MaxValue).Returns(_discoveredOnCommit.AsAsyncEnumerable());

            Stream = new OptimisticEventStream(BucketId, StreamId, Persistence, SystemTimeProvider);
            await Stream.Initialize(StreamRevision, int.MaxValue);

            Stream.Add(_uncommitted);
            //await Stream.CommitChanges(Guid.NewGuid());
        }