public async Task Image_Exception_ApiError() { // Arrange var context = new TestCaseContext(AssetType.Image, Result.ApiError); var sut = new AssetsController( context.Logger, context.SessionManager); // Act var actionResult = await sut.Image( context.Session.Id, ApiRequest <GetAssetRequest> .Make(new GetAssetRequest { Key = context.AssetKey }), CancellationToken.None); // Assert Assert.NotNull(actionResult); var objectResult = actionResult.Result as ObjectResult; Assert.NotNull(objectResult); Assert.Equal(500, objectResult.StatusCode); var result = objectResult.Value as ApiResponse <ImageAssetResponse>; Assert.NotNull(result); Assert.False(result.Success); Assert.NotNull(result.Error); Assert.Null(result.Payload); }
public async Task Image_Success() { // Arrange var context = new TestCaseContext(AssetType.Image, Result.Success); var sut = new AssetsController( context.Logger, context.SessionManager); // Act var actionResult = await sut.Image( context.Session.Id, ApiRequest <GetAssetRequest> .Make(new GetAssetRequest { Key = context.AssetKey }), CancellationToken.None); // Assert Assert.NotNull(actionResult); var objectResult = actionResult.Result as ObjectResult; Assert.NotNull(objectResult); Assert.Equal(200, objectResult.StatusCode); var result = objectResult.Value as ApiResponse <ImageAssetResponse>; Assert.NotNull(result); Assert.True(result.Success); Assert.Null(result.Error); var payload = result.Payload; Assert.NotNull(payload); Assert.Equal(context.AssetKey, payload.Key); Assert.Equal(context.Asset.Descriptor.MediaType, payload.MediaType); Assert.Equal(context.Asset.Descriptor.SourceUrl, payload.SourceUrl); }