Ejemplo n.º 1
0
        public async Task Should_invoke_grain_when_command_is_correct()
        {
            var command = new MatchingCommand {
                AggregateId = id
            };
            var context = new CommandContext(command, A.Fake <ICommandBus>());

            A.CallTo(() => grain.ExecuteAsync(command))
            .Returns(100);

            await sut.HandleAsync(context);

            Assert.Equal(100, context.Result <int>());
        }
Ejemplo n.º 2
0
        public async Task Should_remove_grain_from_cache_when_failed()
        {
            var command = new MatchingCommand {
                AggregateId = id
            };
            var context = new CommandContext(command, A.Fake <ICommandBus>());

            A.CallTo(() => grain.ExecuteAsync(command))
            .Throws(new InvalidOperationException());

            await Assert.ThrowsAsync <InvalidOperationException>(() => sut.HandleAsync(context));

            A.CallTo(() => factory.Synchronize <MyGrain, Guid>(id))
            .MustNotHaveHappened();
            A.CallTo(() => factory.Remove <MyGrain, Guid>(id))
            .MustHaveHappened();
        }
Ejemplo n.º 3
0
        public async Task Should_invoke_grain_when_command_is_correct()
        {
            var command = new MatchingCommand {
                AggregateId = id
            };
            var context = new CommandContext(command, A.Fake <ICommandBus>());

            A.CallTo(() => grain.ExecuteAsync(command))
            .Returns(100);

            await sut.HandleAsync(context);

            Assert.Equal(100, context.Result <int>());

            A.CallTo(() => factory.Synchronize <MyGrain, Guid>(id))
            .MustHaveHappened();
            A.CallTo(() => factory.Remove <MyGrain, Guid>(id))
            .MustNotHaveHappened();
        }