示例#1
0
        public void GivenTheAggregateAndTheEventAggregateThenAnInstanceIsReturnedWithAllPropertiesSet()
        {
            var subject        = new SerializableAggregateRoot();
            var aggregate      = subject.ToReference();
            var eventAggregate = subject.ToReference();
            var instance       = new AggregateEventMismatchException(aggregate, eventAggregate);

            Assert.Equal(aggregate, instance.Aggregate);
            Assert.Equal(eventAggregate, instance.EventAggregate);
        }
示例#2
0
        public void GivenAnInstanceThenAllPropertiesAreSerialized()
        {
            var       subject        = new SerializableAggregateRoot();
            Reference aggregate      = subject.ToReference();
            Reference eventAggregate = subject.ToReference();
            var       original       = new AggregateEventMismatchException(aggregate, eventAggregate);
            AggregateEventMismatchException deserialized = original.Clone();

            Assert.NotSame(original, deserialized);
            Assert.Equal(original.Aggregate, deserialized.Aggregate);
            Assert.Equal(original.EventAggregate, deserialized.EventAggregate);
        }
        public void GivenEventsForADifferentAggregateIdThenAnAggregateEventMismatchExceptionIsThrown()
        {
            var first   = new SerializableEventCentricAggregateRoot();
            var second  = new SerializableEventCentricAggregateRoot();
            var context = new SerializableMessage();

            IEnumerable <DomainEvent> events = first.ApplyChanges(context, times: 1);

            AggregateEventMismatchException exception = Assert.Throws <AggregateEventMismatchException>(
                () => second.LoadFromHistory(events));

            Assert.True(exception.Aggregate.IsMatch(second));
        }