public async Task CreateRenditionAsync_ByAssetReference_CreatesRenditions(Reference assetReference) { var client = _fileSystemFixture.CreateMockClientWithResponse("AssetRendition.json"); var expected = _fileSystemFixture.GetExpectedResponse <AssetRenditionModel>("AssetRendition.json"); var createModel = new AssetRenditionCreateModel { ExternalId = "rendition-1", Transformation = new RectangleResizeTransformation { CustomWidth = 120, CustomHeight = 240, X = 300, Y = 200, Width = 360, Height = 720, } }; var response = await client.CreateAssetRenditionAsync(assetReference, createModel); using (new AssertionScope()) { response.Transformation.Should().BeEquivalentTo(createModel.Transformation); response.ExternalId.Should().BeEquivalentTo(expected.ExternalId); response.AssetId.Should().Be(expected.AssetId); response.RenditionId.Should().Be(expected.RenditionId); } }
public async Task CreateRenditionAsync_IdentifierIsNull_Throws() { var client = _fileSystemFixture.CreateMockClientWithResponse("AssetRendition.json"); var createModel = new AssetRenditionCreateModel { ExternalId = "rendition-1", Transformation = new RectangleResizeTransformation { CustomWidth = 120, CustomHeight = 240, X = 300, Y = 200, Width = 360, Height = 720, } }; await client.Invoking(x => x.CreateAssetRenditionAsync(null, createModel)) .Should().ThrowExactlyAsync <ArgumentNullException>(); }
/// <inheritdoc /> public async Task <AssetRenditionModel> CreateAssetRenditionAsync(Reference assetIdentifier, AssetRenditionCreateModel createModel) { if (assetIdentifier == null) { throw new ArgumentNullException(nameof(assetIdentifier)); } if (createModel == null) { throw new ArgumentNullException(nameof(createModel)); } var endpointUrl = _urlBuilder.BuildAssetRenditionsUrl(assetIdentifier); return(await _actionInvoker.InvokeMethodAsync <AssetRenditionCreateModel, AssetRenditionModel>(endpointUrl, HttpMethod.Post, createModel)); }