Exemple #1
0
        public void FailToAttachPolicyIfRequiredEnvelopeKeyNotPresent()
        {
            var asset = _mediaContext.Assets.Create("Asset for FailToAttachPolicyIfRequiredEnvelopeKeyNotPresent", AssetCreationOptions.None);

            // Do not create or attach a content key

            IAssetDeliveryPolicy policy = CreateEnvelopePolicy("Policy for FailToAttachPolicyIfRequiredEnvelopeKeyNotPresent");

            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.DynamicEnvelopeEncryption when no ContentKey with ContentKeyType.EnvelopeEncryption is linked to it"));

                throw;
            }
            finally
            {
                asset.Delete();
                policy.Delete();
            }
        }
Exemple #2
0
        private void DeleteDeliveryPolicyAndVerify(IAssetDeliveryPolicy policy)
        {
            string id = policy.Id;

            policy.Delete();

            IAssetDeliveryPolicy policyToCheck = _mediaContext.AssetDeliveryPolicies.Where(p => p.Id == id).FirstOrDefault();

            Assert.IsNull(policyToCheck);
        }
Exemple #3
0
        private void DoDeleteDelPol()
        {
            if (listViewPolicies.SelectedIndices.Count > 0)
            {
                string question;
                int    nbError    = 0;
                string messagestr = "";

                if (listViewPolicies.SelectedIndices.Count == 1)
                {
                    question = "Are you sure that you want to DELETE this policy from the Azure Media Services account ?";
                }
                else
                {
                    question = string.Format("Are you sure that you want to DELETE these {0} policies from the Azure Media Services account ?", listViewPolicies.SelectedIndices.Count);
                }

                if (MessageBox.Show(question, "Delivery policy deletion", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    this.Cursor = Cursors.WaitCursor;
                    foreach (var ind in listViewPolicies.SelectedIndices)
                    {
                        IAssetDeliveryPolicy DelPol = delPolicies.Skip((int)ind).Take(1).FirstOrDefault();

                        if (DelPol != null)
                        {
                            try
                            {
                                DelPol.Delete();
                            }
                            catch (Exception e)
                            {
                                nbError++;
                                if (e.InnerException != null)
                                {
                                    messagestr = Program.GetErrorMessage(e);
                                }
                            }
                        }
                    }
                    this.Cursor = Cursors.Default;

                    if (nbError > 0)
                    {
                        messagestr = string.Format("Error when deleting {0} delivery policies.", nbError) + Constants.endline + messagestr;
                        MessageBox.Show(messagestr);
                    }

                    ListPolicies();
                }
            }
        }
        private void DeleteDeliveryPolicyAndVerify(IAssetDeliveryPolicy policy)
        {
            string id = policy.Id;

            policy.Delete();

            IAssetDeliveryPolicy policyToCheck = _mediaContext.AssetDeliveryPolicies.Where(p => p.Id == id).FirstOrDefault();
            Assert.IsNull(policyToCheck);
        }