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

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

            var command = CreateFromClient(appId.Name);

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

            await sut.HandleAsync(context);

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

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

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

            A.CallTo(() => indexForUser.AddAsync(appId.Id))
            .MustNotHaveHappened();
        }
Exemple #2
0
        public async Task Should_not_add_to_indexes_if_name_is_taken()
        {
            var token = RandomHash.Simple();

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

            A.CallTo(() => cache.GetAppIdsAsync(A <string[]> .That.Is(appId.Name)))
            .Returns(new List <DomainId> {
                appId.Id
            });

            var command = Create(appId.Name);

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

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

            A.CallTo(() => cache.AddAsync(A <DomainId> ._, A <string> ._))
            .MustNotHaveHappened();

            A.CallTo(() => cache.RemoveReservationAsync(token))
            .MustHaveHappened();
        }
Exemple #3
0
        public AppImage(string mimeType, string?etag = null)
        {
            Guard.NotNullOrEmpty(mimeType, nameof(mimeType));

            MimeType = mimeType;

            if (string.IsNullOrWhiteSpace(etag))
            {
                Etag = RandomHash.Simple();
            }
            else
            {
                Etag = etag;
            }
        }
Exemple #4
0
        public async Task Should_clear_reservation_when_schema_creation_failed()
        {
            var token = RandomHash.Simple();

            A.CallTo(() => index.ReserveAsync(schemaId.Id, schemaId.Name))
            .Returns(token);

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

            await sut.HandleAsync(context);

            A.CallTo(() => index.AddAsync(token))
            .MustNotHaveHappened();

            A.CallTo(() => index.RemoveReservationAsync(token))
            .MustHaveHappened();
        }
Exemple #5
0
        public async Task Should_add_schema_to_index_on_create()
        {
            var token = RandomHash.Simple();

            A.CallTo(() => index.ReserveAsync(schemaId.Id, schemaId.Name))
            .Returns(token);

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

            await sut.HandleAsync(context);

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

            A.CallTo(() => index.RemoveReservationAsync(A <string> .Ignored))
            .MustNotHaveHappened();
        }
Exemple #6
0
        public async Task Should_clear_reservation_if_app_creation_failed()
        {
            var token = RandomHash.Simple();

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

            var command = CreateFromClient(appId.Name);

            var context =
                new CommandContext(command, commandBus);

            await sut.HandleAsync(context);

            A.CallTo(() => cache.AddAsync(A <DomainId> ._, A <string> ._))
            .MustNotHaveHappened();

            A.CallTo(() => cache.RemoveReservationAsync(token))
            .MustHaveHappened();
        }
Exemple #7
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();
        }
Exemple #8
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> ._))
            .MustNotHaveHappened();

            A.CallTo(() => indexByUser.AddAsync(appId.Id))
            .MustHaveHappened();
        }
Exemple #9
0
        public async Task Should_clear_reservation_when_app_creation_failed()
        {
            var token = RandomHash.Simple();

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

            var command = CreateFromClient(appId.Name);

            var context =
                new CommandContext(command, commandBus);

            await sut.HandleAsync(context);

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

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

            A.CallTo(() => indexForUser.AddAsync(appId.Id))
            .MustNotHaveHappened();
        }