Ejemplo n.º 1
0
 protected override Task Because()
 {
     Stream.Add(new EventMessage {
         Body = MyEvent
     });
     return(Task.FromResult(true));
 }
 protected override Task Because()
 {
     _thrown = Catch.Exception(() => Stream.Add(new EventMessage {
         Body = null
     }));
     return(Task.CompletedTask);
 }
Ejemplo n.º 3
0
 protected override Task Context()
 {
     Stream.Add(new EventMessage {
         Body = string.Empty
     });
     return(Task.FromResult(true));
 }
Ejemplo n.º 4
0
        private void Apply(IEvent @event, IDictionary <string, string> metadata = null)
        {
            RouteFor(@event);

            // Todo: Fill with user headers or something
            Stream.Add(@event, metadata);
        }
 protected override Task Context()
 {
     Stream.Add(new EventMessage {
         Body = string.Empty
     });
     return(Task.CompletedTask);
 }
 protected override Task Because()
 {
     Stream.Add(new EventMessage {
         Body = MyEvent
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 7
0
 protected override void Context()
 {
     Persistence.Setup(x => x.Commit(It.IsAny <Commit>())).Callback <Commit>(x => constructed = x);
     Stream.Add(uncommitted);
     foreach (var item in headers)
     {
         Stream.UncommittedHeaders[item.Key] = item.Value;
     }
 }
Ejemplo n.º 8
0
 protected override void Because()
 {
     Stream.Add(new EventMessage {
         Body = "populated"
     });
     Stream.Add(new EventMessage {
         Body = "also populated"
     });
 }
Ejemplo n.º 9
0
        private void Apply(IEvent @event)
        {
            RouteFor(@event);

            // Todo: Fill with user headers or something
            var headers = new Dictionary <string, string>();

            Stream.Add(@event, headers);
        }
Ejemplo n.º 10
0
 protected override Task Because()
 {
     Stream.Add(new EventMessage {
         Body = "populated"
     });
     Stream.Add(new EventMessage {
         Body = "also populated"
     });
     return(Task.FromResult(true));
 }
 protected override Task Because()
 {
     Stream.Add(new EventMessage {
         Body = "populated"
     });
     Stream.Add(new EventMessage {
         Body = "also populated"
     });
     return(Task.CompletedTask);
 }
 protected override void Because()
 {
     Stream.Add(new EventMessage()
     {
         Body = "Test"
     });
     // this should fail and cause the stream to be reloaded
     _thrown1 = Catch.Exception(() => Stream.CommitChanges(Guid.NewGuid()));
     // this should succeed, events will be appended at the end
     _thrown2 = Catch.Exception(() => Stream.CommitChanges(Guid.NewGuid()));
 }
Ejemplo n.º 13
0
        protected void Apply <TEvent>(Action <TEvent> action) where TEvent : IEvent
        {
            var @event = _eventFactory.CreateInstance(action);

            Raise(@event);

            // Todo: Fill with user headers or something
            var headers = new Dictionary <String, String>();

            Stream.Add(@event, headers);
        }
Ejemplo n.º 14
0
        void IEventSource.Conflict(IEvent @event, IDictionary <string, string> metadata)
        {
            try
            {
                RouteForConflict(@event);
                RouteFor(@event);

                // Todo: Fill with user headers or something
                var headers = new Dictionary <string, string>();
                Stream.Add(@event, metadata);
            }
            catch (DiscardEventException) { }
        }
Ejemplo n.º 15
0
        public static Stream Add(this Stream stream, IConvertible val)
        {
            byte[] data;
            if (val.GetType() == typeof(string))
            {
                data = val != null?val.GetBytes() : String.Empty.GetBytes();

                var lengthBytes = data.Length.GetBytes();
                stream.Write(lengthBytes, 0, lengthBytes.Length);
            }
            else
            {
                data = val.GetBytes();
            }
            return(stream.Add(data));
        }
Ejemplo n.º 16
0
 protected override void Context()
 {
     Persistence
     .Setup(x => x.Commit(It.IsAny <CommitAttempt>()))
     .Callback <CommitAttempt>(x => _constructed = x)
     .Returns((CommitAttempt attempt) => new Commit(
                  attempt.BucketId, attempt.StreamId,
                  attempt.StreamRevision,
                  attempt.CommitId,
                  attempt.CommitSequence,
                  attempt.CommitStamp,
                  new IntCheckpoint(0).Value,
                  attempt.Headers,
                  attempt.Events));
     Stream.Add(_uncommitted);
     foreach (var item in _headers)
     {
         Stream.UncommittedHeaders[item.Key] = item.Value;
     }
 }
 protected override void Context()
 {
     A.CallTo(() => Persistence.Commit(A <CommitAttempt> ._))
     .Invokes((CommitAttempt _) => _constructed = _)
     .ReturnsLazily((CommitAttempt attempt) => new Commit(
                        attempt.BucketId,
                        attempt.StreamId,
                        attempt.StreamRevision,
                        attempt.CommitId,
                        attempt.CommitSequence,
                        attempt.CommitStamp,
                        0,
                        attempt.Headers,
                        attempt.Events));
     Stream.Add(_uncommitted);
     foreach (var item in _headers)
     {
         Stream.UncommittedHeaders[item.Key] = item.Value;
     }
 }
Ejemplo n.º 18
0
        protected override Task Context()
        {
            Persistence
            .Commit(Arg.Any <CommitAttempt>())
            .Returns(c =>
            {
                var attempt  = c.Arg <CommitAttempt>();
                _constructed = attempt;
                return(new Commit(
                           attempt.BucketId,
                           attempt.StreamId,
                           attempt.StreamRevision,
                           attempt.CommitId,
                           attempt.CommitSequence,
                           attempt.CommitStamp,
                           new LongCheckpoint(0).Value,
                           attempt.Headers,
                           attempt.Events
                           ));
            });

            //A.CallTo(() => Persistence.Commit(A<CommitAttempt>._))
            //    .Invokes((CommitAttempt _) => _constructed = _)
            //    .ReturnsLazily((CommitAttempt attempt) => new Commit(
            //        attempt.BucketId,
            //        attempt.StreamId,
            //        attempt.StreamRevision,
            //        attempt.CommitId,
            //        attempt.CommitSequence,
            //        attempt.CommitStamp,
            //        new LongCheckpoint(0).Value,
            //        attempt.Headers,
            //        attempt.Events));
            Stream.Add(_uncommitted);
            foreach (var item in _headers)
            {
                Stream.UncommittedHeaders[item.Key] = item.Value;
            }
            return(Task.FromResult(true));
        }
 protected override Task Because()
 {
     _thrown = Catch.Exception(() => Stream.Add(null));
     return(Task.CompletedTask);
 }
Ejemplo n.º 20
0
 protected override void Context()
 {
     Stream.Add(new EventMessage {
         Body = string.Empty
     });
 }
Ejemplo n.º 21
0
 protected override void Because()
 {
     Stream.Add(new EventMessage {
         Body = MyEvent
     });
 }
Ejemplo n.º 22
0
 protected override Task Because()
 {
     Stream.Add(null);
     return(Task.FromResult(true));
 }
Ejemplo n.º 23
0
 protected override void Because()
 {
     Stream.Add(null);
 }
 protected override void Because()
 {
     _thrown = Catch.Exception(() => Stream.Add(new EventMessage {
         Body = null
     }));
 }
 protected override void Because()
 {
     _thrown = Catch.Exception(() => Stream.Add(null));
 }