Skip to content

Commit

Permalink
adding asset clone test
Browse files Browse the repository at this point in the history
  • Loading branch information
JackLewis-digirati committed May 29, 2024
1 parent 3eabc98 commit ac541d9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@ Task<CreateJobResponse> CreateJob(string inputKey, string pipelineId, List<Creat
/// <param name="cancellationToken">Current cancellation token</param>
/// <returns>Job details, if found. Else null</returns>
Task<TranscoderJob?> GetTranscoderJob(AssetId assetId, CancellationToken cancellationToken);


}
65 changes: 64 additions & 1 deletion src/protagonist/DLCS.Model.Tests/Assets/AssetTests.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<ImageDeliveryChannel>()
{
new()
{
DeliveryChannelPolicyId = KnownDeliveryChannelPolicies.ImageDefault,
Channel = AssetDeliveryChannels.Image,
DeliveryChannelPolicy = new DeliveryChannelPolicy()
{
Id = KnownDeliveryChannelPolicies.ImageDefault,
Channel = AssetDeliveryChannels.Image
}
}
},
AssetApplicationMetadata = new List<AssetApplicationMetadata>()
{
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);
}
}

0 comments on commit ac541d9

Please sign in to comment.