Exemplo n.º 1
0
        private void SetupCreated(params IEvent[] @events)
        {
            var handleEvent = new HandleEvent(_ => true);

            var version = -1;

            A.CallTo(() => persistence.ReadAsync(-2))
            .Invokes(() =>
            {
                version++;

                foreach (var @event in events)
                {
                    handleEvent(Envelope.Create(@event));
                }
            });

            A.CallTo(() => persistenceFactory.WithSnapshotsAndEventSourcing(typeof(MyDomainObject), id, A <HandleSnapshot <MyDomainState> > ._, A <HandleEvent> ._))
            .Invokes(args =>
            {
                handleEvent = args.GetArgument <HandleEvent>(3) !;
            })
            .Returns(persistence);

            A.CallTo(() => persistence.Version)
            .ReturnsLazily(() => version);

            sut.Setup(id);
        }
Exemplo n.º 2
0
        private void SetupCreated(int value)
        {
            var handleEvent = new HandleEvent(_ => true);

            var version = -1;

            A.CallTo(() => persistence.ReadAsync(-2))
            .Invokes(() =>
            {
                version = 0;

                handleEvent(Envelope.Create(new ValueChanged {
                    Value = value
                }));
            });

            A.CallTo(() => store.WithSnapshotsAndEventSourcing(typeof(MyDomainObject), id, A <HandleSnapshot <MyDomainState> > ._, A <HandleEvent> ._))
            .Invokes(args =>
            {
                handleEvent = args.GetArgument <HandleEvent>(3) !;
            })
            .Returns(persistence);

            A.CallTo(() => persistence.Version)
            .ReturnsLazily(() => version);

            sut.Setup(id);
        }
Exemplo n.º 3
0
        private async Task SetupCreatedAsync()
        {
            sut.Setup(id);

            await sut.ExecuteAsync(new CreateAuto { Value = 4 });
        }