public async Task ignore_resolver()
        {
            var store     = new Moq.Mock <IStoreEvents>();
            var streamGen = new StreamIdGenerator((type, stream, bucket, id, parents) => "test");

            var fullevent = new Moq.Mock <IFullEvent>();

            fullevent.Setup(x => x.Event).Returns(new Event());

            _stream.Setup(x => x.Add(Moq.It.IsAny <IEvent>(), Moq.It.IsAny <IDictionary <string, string> >()));
            store.Setup(
                x => x.WriteEvents("test", new[] { fullevent.Object }, Moq.It.IsAny <IDictionary <string, string> >(), null))
            .Returns(Task.FromResult(0L));

            // Ignores conflict, just commits
            var resolver = new IgnoreConflictResolver(store.Object, streamGen);

            var entity = new Entity(_stream.Object, _resolver.Object);


            await resolver.Resolve(entity, new[] { fullevent.Object }, Guid.NewGuid(), new Dictionary <string, string>())
            .ConfigureAwait(false);

            _stream.Verify(x => x.Add(Moq.It.IsAny <IEvent>(), Moq.It.IsAny <IDictionary <string, string> >()),
                           Moq.Times.Once);
            store.Verify(
                x => x.WriteEvents("test", new[] { fullevent.Object }, Moq.It.IsAny <IDictionary <string, string> >(), null),
                Moq.Times.Once);
        }
Exemplo n.º 2
0
        async Task IgnoreConflictResolverWritesEvents()
        {
            var store = Fake <IStoreEvents>();
            var sut   = new IgnoreConflictResolver(store, Fake <IOobWriter>());

            await sut.Resolve <FakeEntity, FakeState>(Fake <FakeEntity>(), Fake <Guid>(), Fake <Dictionary <string, string> >()).ConfigureAwait(false);

            A.CallTo(() =>
                     store.WriteEvents <FakeEntity>(A <string> .Ignored, A <Id> .Ignored, A <Id[]> .Ignored, A <IFullEvent[]> .Ignored, A <Dictionary <string, string> > .Ignored, A <long?> .Ignored))
            .Should().HaveHappenedOnce();
        }
        async Task IgnoreConflictResolverWritesOobEvents()
        {
            var store  = Fake <IStoreEvents>();
            var oob    = Fake <IOobWriter>();
            var entity = Fake <FakeEntity>();

            var sut = new IgnoreConflictResolver(store, oob);

            entity.RaiseEvents(Many <FakeOobEvent.FakeEvent>(3), "test");

            await sut.Resolve <FakeEntity, FakeState>(entity, Fake <Guid>(), Fake <Dictionary <string, string> >()).ConfigureAwait(false);

            // No domain events writen
            A.CallTo(() =>
                     store.WriteEvents <FakeEntity>(A <string> .Ignored, A <Id> .Ignored, A <Id[]> .Ignored, A <IFullEvent[]> .That.IsEmpty(), A <Dictionary <string, string> > .Ignored, A <long?> .Ignored))
            .Should().HaveHappened();
            A.CallTo(() =>
                     oob.WriteEvents <FakeEntity>(A <string> .Ignored, A <Id> .Ignored, A <Id[]> .Ignored, A <IFullEvent[]> .That.Matches(x => x.Length == 3), A <Guid> .Ignored, A <Dictionary <string, string> > .Ignored))
            .Should().HaveHappened();
        }
Exemplo n.º 4
0
        public async Task ignore_resolver()
        {
            var streamGen = new StreamIdGenerator((type, stream, bucket, id, parents) => "test");

            var fullevent = new Moq.Mock <IFullEvent>();

            fullevent.Setup(x => x.Event).Returns(new Event());

            _store.Setup(x => x.WriteEvents <FakeEntity>(Moq.It.IsAny <string>(), Moq.It.IsAny <Id>(), Moq.It.IsAny <Id[]>(), Moq.It.IsAny <IFullEvent[]>(), Moq.It.IsAny <IDictionary <string, string> >(), Moq.It.IsAny <long?>()))
            .Returns(Task.FromResult(0L));

            // Ignores conflict, just commits
            var resolver = new IgnoreConflictResolver(_store.Object, streamGen);

            var entity = new FakeEntity();

            (entity as IEntity <FakeState>).Instantiate(new FakeState());


            await resolver.Resolve <FakeEntity, FakeState>(entity, new[] { fullevent.Object }, Guid.NewGuid(), new Dictionary <string, string>())
            .ConfigureAwait(false);

            _store.Verify(x => x.WriteEvents <FakeEntity>(Moq.It.IsAny <string>(), Moq.It.IsAny <Id>(), Moq.It.IsAny <Id[]>(), Moq.It.IsAny <IFullEvent[]>(), Moq.It.IsAny <IDictionary <string, string> >(), Moq.It.IsAny <long?>()), Moq.Times.Once);
        }