Example #1
0
        public async Task Should_add_app_to_indexes_if_creating()
        {
            var token = RandomHash.Simple();

            A.CallTo(() => cache.ReserveAsync(appId.Id, appId.Name))
            .Returns(token);

            var command = Create(appId.Name);

            var context =
                new CommandContext(command, commandBus)
                .Complete();

            await sut.HandleAsync(context);

            A.CallTo(() => cache.AddAsync(appId.Id, appId.Name))
            .MustHaveHappened();

            A.CallTo(() => cache.RemoveReservationAsync(token))
            .MustHaveHappened();
        }
Example #2
0
        public async Task Should_add_app_to_indexes_on_create()
        {
            var token = RandomHash.Simple();

            A.CallTo(() => indexByName.ReserveAsync(appId.Id, appId.Name))
            .Returns(token);

            var context =
                new CommandContext(Create(appId.Name), commandBus)
                .Complete();

            await sut.HandleAsync(context);

            A.CallTo(() => indexByName.AddAsync(token))
            .MustHaveHappened();

            A.CallTo(() => indexByName.RemoveReservationAsync(A <string> .Ignored))
            .MustNotHaveHappened();

            A.CallTo(() => indexByUser.AddAsync(appId.Id))
            .MustHaveHappened();
        }