public void RaiseEvent_has_null_guard_clause()
        {
            var    sut    = new EventSourcedProxy(Guid.NewGuid());
            Action action = () => sut.RaiseEvent <SomeDomainEvent>(null);

            action.ShouldThrow <ArgumentNullException>().Which.ParamName.Should().Be("domainEvent");
        }
        public void HandlePastEvents_has_guard_clause_against_invalid_Version()
        {
            var sut = new EventSourcedProxy(Guid.NewGuid());

            sut.SetEventHandler <SomeDomainEvent>(e => { });
            IDomainEvent[] pastEvents = new IDomainEvent[]
            {
                new SomeDomainEvent
                {
                    SourceId = sut.Id,
                    Version  = 1,
                    RaisedAt = DateTime.UtcNow,
                    Property = Guid.NewGuid(),
                },
                new SomeDomainEvent
                {
                    SourceId = sut.Id,
                    Version  = 1,
                    RaisedAt = DateTime.UtcNow,
                    Property = Guid.NewGuid(),
                },
            };

            Action action = () => sut.HandlePastEvents(pastEvents);

            action.ShouldThrow <ArgumentException>();
        }
        public void SetEventHandler_has_guard_clause_against_duplicate_event_type()
        {
            var sut = new EventSourcedProxy(Guid.NewGuid());

            sut.SetEventHandler <SomeDomainEvent>(e => { });

            Action action = () => sut.SetEventHandler <SomeDomainEvent>(e => { });

            action.ShouldThrow <InvalidOperationException>();
        }
        public void HandlePastEvents_fails_for_unknown_domain_event_type()
        {
            var sut = new EventSourcedProxy(Guid.NewGuid());

            IDomainEvent[] pastEvents = new IDomainEvent[]
            {
                new SomeDomainEvent
                {
                    SourceId = sut.Id,
                    Version  = 1,
                    RaisedAt = DateTime.UtcNow,
                    Property = Guid.NewGuid(),
                },
            };

            Action action = () => sut.HandlePastEvents(pastEvents);

            action.ShouldThrow <InvalidOperationException>();
        }