Esempio n. 1
0
        public void Appending_an_event_while_it_is_not_owned_by_any_source_should_cause_an_exception()
        {
            var target = new SourcedEventStream();
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), Guid.NewGuid(), 1, DateTime.UtcNow);

            Action act = () => target.Append(anSourcedEvent);
            act.ShouldThrow<ArgumentException>();
        }
Esempio n. 2
0
        public void Appending_an_event_that_does_not_hold_EventSourceId_and_Sequence_should_be_accepted()
        {
            var target = new SourcedEventStream();
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), SourcedEvent.UndefinedEventSourceId, SourcedEvent.UndefinedEventSequence, DateTime.UtcNow);

            Action act = () => target.Append(anSourcedEvent);
            act.ShouldNotThrow();
        }
Esempio n. 3
0
        public void Appending_an_event_while_it_is_not_owned_by_any_source_should_cause_an_exception()
        {
            var target         = new SourcedEventStream();
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), Guid.NewGuid(), 1, DateTime.UtcNow);

            Action act = () => target.Append(anSourcedEvent);

            act.ShouldThrow <InvalidOperationException>();
        }
Esempio n. 4
0
        public void Appending_an_event_that_does_not_hold_EventSourceId_and_Sequence_should_be_accepted()
        {
            var target         = new SourcedEventStream();
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), UndefinedValues.UndefinedEventSourceId, UndefinedValues.UndefinedEventSequence, DateTime.UtcNow);

            Action act = () => target.Append(anSourcedEvent);

            act.ShouldNotThrow();
        }
Esempio n. 5
0
        public void Adding_first_event_should_cause_IsEmpty_property_to_be_false()
        {
            var anEventSourceId = Guid.NewGuid();
            var target = new SourcedEventStream(anEventSourceId);
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), anEventSourceId, 1, DateTime.UtcNow);

            target.Append(anSourcedEvent);

            target.IsEmpty.Should().BeFalse();
        }
Esempio n. 6
0
        public void Setting_the_event_source_id_while_there_are_already_events_in_the_stream_should_cause_exception()
        {
            var anEventSourceId = Guid.NewGuid();
            var target = new SourcedEventStream(anEventSourceId);
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), anEventSourceId, SourcedEvent.UndefinedEventSequence, DateTime.UtcNow);

            target.Append(anSourcedEvent);

            Action act = () => target.EventSourceId = Guid.NewGuid();
            act.ShouldThrow<InvalidOperationException>();
        }
Esempio n. 7
0
        public void Appending_an_event_with_sequence_should_cause_an_exception()
        {
            var anEventSourceId = Guid.NewGuid();
            var wrongSequence = 999;

            var target = new SourcedEventStream(anEventSourceId);
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), SourcedEvent.UndefinedEventSourceId, wrongSequence, DateTime.UtcNow);

            Action act = () => target.Append(anSourcedEvent);
            act.ShouldThrow<ArgumentException>();
        }
Esempio n. 8
0
        public void Appending_an_event_should_cause_the_event_owner_info_to_be_set()
        {
            var eventSourceId = Guid.NewGuid();
            var target = new SourcedEventStream(eventSourceId);
            var theSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), SourcedEvent.UndefinedEventSourceId, SourcedEvent.UndefinedEventSequence, DateTime.UtcNow);

            target.Append(theSourcedEvent);

            theSourcedEvent.EventSourceId.Should().Be(eventSourceId);
            theSourcedEvent.EventSequence.Should().Be(1);
        }
Esempio n. 9
0
        public void Adding_first_event_should_cause_IsEmpty_property_to_be_false()
        {
            var anEventSourceId = Guid.NewGuid();
            var target          = new SourcedEventStream(anEventSourceId);
            var anSourcedEvent  = new SourcedEventFoo(Guid.NewGuid(), UndefinedValues.UndefinedEventSourceId,
                                                      UndefinedValues.UndefinedEventSequence, DateTime.Now);

            target.Append(anSourcedEvent);

            target.IsEmpty.Should().BeFalse();
        }
Esempio n. 10
0
        public void Appending_an_event_should_cause_the_event_owner_info_to_be_set()
        {
            var eventSourceId   = Guid.NewGuid();
            var target          = new SourcedEventStream(eventSourceId);
            var theSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), UndefinedValues.UndefinedEventSourceId, UndefinedValues.UndefinedEventSequence, DateTime.UtcNow);

            target.Append(theSourcedEvent);

            theSourcedEvent.EventSourceId.Should().Be(eventSourceId);
            theSourcedEvent.EventSequence.Should().Be(1);
        }
Esempio n. 11
0
        public void Setting_the_event_source_id_while_there_are_already_events_in_the_stream_should_cause_exception()
        {
            var anEventSourceId = Guid.NewGuid();
            var target          = new SourcedEventStream(anEventSourceId);
            var anSourcedEvent  = new SourcedEventFoo(Guid.NewGuid(), UndefinedValues.UndefinedEventSourceId, UndefinedValues.UndefinedEventSequence, DateTime.UtcNow);

            target.Append(anSourcedEvent);

            Action act = () => target.EventSourceId = Guid.NewGuid();

            act.ShouldThrow <InvalidOperationException>();
        }
Esempio n. 12
0
        public void Appending_an_event_with_sequence_should_cause_an_exception()
        {
            var anEventSourceId = Guid.NewGuid();
            var wrongSequence   = 999;

            var target         = new SourcedEventStream(anEventSourceId);
            var anSourcedEvent = new SourcedEventFoo(Guid.NewGuid(), UndefinedValues.UndefinedEventSourceId, wrongSequence, DateTime.UtcNow);

            Action act = () => target.Append(anSourcedEvent);

            act.ShouldThrow <InvalidOperationException>();
        }