예제 #1
0
        public async Task AttachmentExists_EndToEnd()
        {
            var attachmentName = $"{base.GetRandomName}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut");

            var createResponse = await AttachmentClient.CreateAsset("aut", new[]
            {
                new StreamPart(AssetLoader.AsStream(AssetLoader.App1Asset2Name), attachmentName, "image/jpeg")
            });

            var exists = await AttachmentClient.AttachmentExists("aut", attachmentName);

            exists.Should().BeTrue();

            var id             = createResponse.Id;
            var deleteResponse = await AttachmentClient.DeleteAsset("aut", id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(2));
        }
        public async Task CreateAsset_EndToEnd()
        {
            var attachmentName = $"{base.GetRandomName}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut");

            var createResponse = await AttachmentClient.CreateAsset("aut", new[]
            {
                new StreamPart(AssetLoader.AsStream(AssetLoader.App1Asset2Name), attachmentName, "image/jpeg")
            });

            await AttachmentClient.AssertAttachmentMustExist("aut", attachmentName, delay : TimeSpan.FromSeconds(2));

            // todo : assert the postresponse matches

            var id             = createResponse.Id;
            var deleteResponse = await AttachmentClient.DeleteAsset("aut", id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(2));
        }
        public async Task UpdateAssetTags_EndToEnd()
        {
            var attachmentName = $"{base.GetRandomName}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut");

            var createResponse = await AttachmentClient.CreateAsset("aut", attachmentName, "image/jpeg", AssetLoader.AsStream(AssetLoader.App1Asset2Name));

            await AttachmentClient.AssertAttachmentMustExist("aut", attachmentName, delay : TimeSpan.FromSeconds(2));

            var id           = createResponse.Id;
            var fileName     = createResponse.FileName;
            var existingTags = createResponse.Tags;
            var modifiedTags = existingTags.Append("new-tag").Append("another-new-tag").ToArray();

            await AttachmentClient.UpdateAssetTags("aut", id, new UpdateAssetDto()
            {
                FileName = fileName,
                Tags     = modifiedTags
            });

            var updatedAttachment = await AttachmentClient.GetAsset("aut", id);

            // todo : assert the updatedresponse matches

            var deleteResponse = await AttachmentClient.DeleteAsset("aut", id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(2));
        }
        public async Task GetAllAssets_EndToEnd()
        {
            var attachmen1tName = $"{base.GetRandomName}.jpg";
            var attachment2Name = $"{base.GetRandomName}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut");

            var createResponse1 = await AttachmentClient.CreateAsset("aut", attachmen1tName, "image/jpeg", AssetLoader.AsStream(AssetLoader.App1Asset2Name));

            await AttachmentClient.AssertAttachmentMustExist("aut", attachmen1tName, delay : TimeSpan.FromSeconds(2));

            var createResponse2 = await AttachmentClient.CreateAsset("aut", attachment2Name, "image/jpeg", AssetLoader.AsStream(AssetLoader.App1Asset3Name));

            await AttachmentClient.AssertAttachmentMustExist("aut", attachment2Name, delay : TimeSpan.FromSeconds(2));

            var getAllResponse = await AttachmentClient.GetAllAssets("aut", new ListRequest()
            {
                Skip = 0,
                Top  = 2,
            });

            // todo : assert we got both

            var id1             = createResponse1.Id;
            var id2             = createResponse2.Id;
            var deleteResponse1 = await AttachmentClient.DeleteAsset("aut", id1);

            var deleteResponse2 = await AttachmentClient.DeleteAsset("aut", id2);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(2));
        }
        public async Task AssetTag_Execute_EndToEnd()
        {
            var name1 = $"{GetRandomSchemaName.Substring(0, 10)}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));

            var posted1 = await AttachmentClient.CreateAsset("aut", name1, MimeTypeMap.GetMimeType("jpg"), AssetLoader.AsStream(AssetLoader.App1Asset2Name));

            var updatedTags = posted1.Tags.Append("tag-a").Append("tag-b").ToArray();
            await AssetStories.TagAsset(AttachmentTagSystemUnderTest, "aut", posted1.Id, updatedTags);

            var updated1 = await AttachmentClient.GetAssetByNameOrDefault("aut", name1);

            updated1.Should().NotBeNull();
            updated1.Tags.Should().Contain(updatedTags);

            await AttachmentClient.DeleteAsset("aut", posted1.Id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));
        }
        public async Task AssetList_Execute_EndToEnd()
        {
            var name1 = $"{GetRandomSchemaName.Substring(0, 10)}.jpg";
            var name2 = $"{GetRandomSchemaName.Substring(0, 10)}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));

            var posted1 = await AttachmentClient.CreateAsset("aut", name1, MimeTypeMap.GetMimeType("jpg"), AssetLoader.AsStream(AssetLoader.App1Asset2Name));

            var posted2 = await AttachmentClient.CreateAsset("aut", name2, MimeTypeMap.GetMimeType("jpg"), AssetLoader.AsStream(AssetLoader.App1Asset3Name));

            await AssetStories.ListAsset(AttachmentListSystemUnderTest, "aut");

            // todo : assert expected output to console service

            await AttachmentClient.DeleteAsset("aut", posted1.Id);

            await AttachmentClient.DeleteAsset("aut", posted2.Id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));
        }
        public async Task AssetDelete_Execute_EndToEnd()
        {
            var name1 = $"{GetRandomSchemaName.Substring(0, 10)}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));

            var posted1 = await AttachmentClient.CreateAsset("aut", name1, MimeTypeMap.GetMimeType("jpg"), AssetLoader.AsStream(AssetLoader.App1Asset2Name));

            await AssetStories.DeleteAsset(AttachmentDeleteSystemUnderTest, "aut", posted1.Id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));
        }
        public async Task AssetUpdate_Execute_EndToEnd()
        {
            var name1 = $"{GetRandomSchemaName.Substring(0, 10)}.jpg";

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));

            var posted1 = await AttachmentClient.CreateAsset("aut", name1, MimeTypeMap.GetMimeType("jpg"), AssetLoader.AsStream(AssetLoader.App1Asset2Name));

            await AssetStories.UpdateAsset(AssetUpdateContentSystemUnderTest, "aut", posted1.Id, AssetLoader.AsPath(AssetLoader.App1Asset3Name));

            var updated1 = await AttachmentClient.GetAssetByNameOrDefault("aut", name1);

            updated1.Should().NotBeNull();
            updated1.Id.Should().Be(posted1.Id);
            updated1.Tags.Should().Contain(posted1.Tags);
            updated1.FileName.Should().BeEquivalentTo(posted1.FileName);
            updated1.FileSize.Should().NotBe(posted1.FileSize);

            await AttachmentClient.DeleteAsset("aut", posted1.Id);

            await AttachmentClient.AssertNoAttachmentsExist("aut", delay : TimeSpan.FromSeconds(0.5));
        }