diff --git a/src/protagonist/DLCS.AWS/ElasticTranscoder/IElasticTranscoderWrapper.cs b/src/protagonist/DLCS.AWS/ElasticTranscoder/IElasticTranscoderWrapper.cs index 0ae7cbd79..a70367b47 100644 --- a/src/protagonist/DLCS.AWS/ElasticTranscoder/IElasticTranscoderWrapper.cs +++ b/src/protagonist/DLCS.AWS/ElasticTranscoder/IElasticTranscoderWrapper.cs @@ -64,6 +64,4 @@ Task CreateJob(string inputKey, string pipelineId, ListCurrent cancellation token /// Job details, if found. Else null Task GetTranscoderJob(AssetId assetId, CancellationToken cancellationToken); - - } \ No newline at end of file diff --git a/src/protagonist/DLCS.Model.Tests/Assets/AssetTests.cs b/src/protagonist/DLCS.Model.Tests/Assets/AssetTests.cs index 583525aeb..20e7ae6fc 100644 --- a/src/protagonist/DLCS.Model.Tests/Assets/AssetTests.cs +++ b/src/protagonist/DLCS.Model.Tests/Assets/AssetTests.cs @@ -1,5 +1,9 @@ -using DLCS.Core.Types; +using System.Collections.Generic; +using System.Linq; +using DLCS.Core.Types; using DLCS.Model.Assets; +using DLCS.Model.Assets.Metadata; +using DLCS.Model.Policies; using FluentAssertions; using Xunit; @@ -76,4 +80,63 @@ public void Tags_Convert_From_List() var expected = "a,b,c"; asset.Tags.Should().Be(expected); } + + [Fact] + public void Clone_ClonesObject_From_List() + { + // Arrange + var asset = new Asset + { + Reference1 = "someReference", + Reference2 = "ref2", + ImageDeliveryChannels =new List() + { + new() + { + DeliveryChannelPolicyId = KnownDeliveryChannelPolicies.ImageDefault, + Channel = AssetDeliveryChannels.Image, + DeliveryChannelPolicy = new DeliveryChannelPolicy() + { + Id = KnownDeliveryChannelPolicies.ImageDefault, + Channel = AssetDeliveryChannels.Image + } + } + }, + AssetApplicationMetadata = new List() + { + new() + { + MetadataType = "someType" + } + } + }; + + // Act + var secondAsset = asset.Clone(); + + secondAsset.Reference1 = "someReference updated"; + secondAsset.ImageDeliveryChannels.ToList()[0].DeliveryChannelPolicyId = + KnownDeliveryChannelPolicies.ImageUseOriginal; + secondAsset.ImageDeliveryChannels.Add(new ImageDeliveryChannel + { + DeliveryChannelPolicyId = KnownDeliveryChannelPolicies.AvDefaultVideo, + Channel = AssetDeliveryChannels.Timebased, + DeliveryChannelPolicy = new DeliveryChannelPolicy() + { + Id = KnownDeliveryChannelPolicies.AvDefaultVideo, + Channel = AssetDeliveryChannels.Timebased + } + }); + secondAsset.AssetApplicationMetadata!.ToList()[0].MetadataType = "someType 2"; + + // Assert + secondAsset.Reference1.Should().NotBe(asset.Reference1); + secondAsset.Reference2.Should().Be(asset.Reference2); + secondAsset.ImageDeliveryChannels.ToList()[0].DeliveryChannelPolicyId.Should() + .NotBe(asset.ImageDeliveryChannels.ToList()[0].DeliveryChannelPolicyId); + secondAsset.ImageDeliveryChannels.Count.Should().Be(2); + asset.ImageDeliveryChannels.Count.Should().Be(1); + secondAsset.AssetApplicationMetadata.ToList()[0].MetadataType.Should() + .NotBe(asset.AssetApplicationMetadata.ToList()[0].MetadataType); + } } \ No newline at end of file