Ejemplo n.º 1
0
        public void AggregateRoot_PublishAndApplyEventAsync2ShouldThrowExceptionIfApplyEventMethodDoesntExist()
        {
            var guid = Guid.NewGuid();
            var @event = new TestEvent2();
            var aggregateBus = new Mock<IAggregateBus>();
            aggregateBus.Setup(x => x.PublishAsync<TestAggregateRoot, TestEvent2>(guid, @event)).Returns(Task.FromResult<object>(null)).Verifiable();
            var testAggregateRoot = new TestAggregateRoot(aggregateBus.Object, guid);

            testAggregateRoot.Awaiting(x => x.PublishAndApplyEventAsync<TestEvent2>(@event)).ShouldThrow<ApplicationException>();

            testAggregateRoot.WasApplyEventCalled.Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void AggregateRoot_PublishAndApplyEventAsyncShouldCallApplyEventIfExists()
        {
            var guid = Guid.NewGuid();
            var @event = new TestEvent2();
            var aggregateBus = new Mock<IAggregateBus>();
            aggregateBus.Setup(x => x.PublishAsync<TestAggregateRoot, TestEvent2>(guid, @event)).Returns(Task.FromResult<object>(null)).Verifiable();
            var testAggregateRoot = new TestAggregateRoot(aggregateBus.Object, guid);

            testAggregateRoot.Awaiting(x => x.PublishAndApplyEventAsync<TestAggregateRoot, TestEvent>(new TestEvent())).ShouldNotThrow();

            testAggregateRoot.WasApplyEventCalled.Should().BeTrue();
        }