public void FailToAttachPolicyIfCommonContentKeyNotPresent()
{
var asset = _mediaContext.Assets.Create("Asset for FailToAttachPolicyIfCommonContentKeyNotPresent", AssetCreationOptions.None);
// Do not create or attach a content key
IAssetDeliveryPolicy policy = CreatePlayReadyPolicy("Policy for FailToAttachPolicyIfCommonContentKeyNotPresent");
try
{
asset.DeliveryPolicies.Add(policy);
Assert.Fail("Expected DataServiceRequestException didn't occur.");
}
catch (DataServiceRequestException e)
{
Assert.IsTrue(e.ToString().Contains("Cannot set an AssetDeliveryPolicy specifying AssetDeliveryPolicyType.DynamicCommonEncryption when no ContentKey with ContentKeyType.CommonEncryption is linked to it"));
throw;
}
finally
{
asset.Delete();
policy.Delete();
}
}