Пример #1
0
        public void ShouldThrowCreateWithSingleTaskIfStrategyIsNull()
        {
            var mediaProcessorName             = MediaProcessorNames.MediaEncoderStandard;
            var taskConfiguration              = MediaEncoderStandardTaskPresetStrings.H264SingleBitrate720p;
            var outputAssetName                = "Output Asset Name";
            var outputAssetOptions             = AssetCreationOptions.None;
            IAccountSelectionStrategy strategy = null;

            this.asset = this.context.Assets.CreateFromFile(@"Media\smallwmv1.wmv", AssetCreationOptions.None);

            this.context.Jobs.CreateWithSingleTask(mediaProcessorName, taskConfiguration, this.asset, strategy, outputAssetName, outputAssetOptions);
        }
Пример #2
0
        public void ShouldThrowIfSelectionStrategyIsNullDuringAssetCreate()
        {
            IAccountSelectionStrategy selectionStrategy = null;

            try
            {
                this.asset = this.context.Assets.Create(Guid.NewGuid().ToString(), selectionStrategy, AssetCreationOptions.None);
            }
            catch (ArgumentNullException ane)
            {
                Assert.AreEqual(ane.ParamName, "strategy");
                throw;
            }
        }
Пример #3
0
        public void ShouldThrowIfSelectionStrategyIsNullDuringAssetCreateAsync()
        {
            IAccountSelectionStrategy selectionStrategy = null;
            CancellationToken         token;

            try
            {
                Task <IAsset> assetTask = this.context.Assets.CreateAsync(Guid.NewGuid().ToString(), selectionStrategy, AssetCreationOptions.None, token);
            }
            catch (ArgumentNullException ane)
            {
                Assert.AreEqual(ane.ParamName, "strategy");
                throw;
            }
        }
        /// <summary>
        /// Returns a <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new empty <see cref="IAsset"/> asset within one selected storage account from <paramref name="storageAccountNames"/> based on the default <see cref="IAccountSelectionStrategy"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="assetName">The asset name.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <param name="token">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new empty <see cref="IAsset"/> within one selected storage account from the given <see cref="IAccountSelectionStrategy"/>.</returns>
        public static Task<IAsset> CreateAsync(this AssetBaseCollection assets, string assetName, IAccountSelectionStrategy strategy, AssetCreationOptions options, CancellationToken token)
        {
            if (assets == null)
            {
                throw new ArgumentNullException("assets");
            }

            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccountName = strategy.SelectAccountForAsset();

            return assets.CreateAsync(assetName, storageAccountName, options, token);
        }
        /// <summary>
        /// Returns a new empty <see cref="IAsset"/> within one selected storage account from <paramref name="storageAccountNames"/> based on the default <see cref="IAccountSelectionStrategy"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="assetName">The asset name.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <returns>A new empty <see cref="IAsset"/> within one selected storage account from the provided <see cref="IAccountSelectionStrategy"/>.</returns>
        public static IAsset Create(this AssetBaseCollection assets, string assetName, IAccountSelectionStrategy strategy, AssetCreationOptions options)
        {
            if (assets == null)
            {
                throw new ArgumentNullException("assets");
            }

            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccountName = strategy.SelectAccountForAsset();

            return assets.Create(assetName, storageAccountName, options);
        }
        /// <summary>
        /// Returns a new empty <see cref="IAsset"/> within one selected storage account from <paramref name="storageAccountNames"/> based on the default <see cref="IAccountSelectionStrategy"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="assetName">The asset name.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new output asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <returns>A new empty <see cref="IAsset"/> within one selected storage account from the provided <see cref="IAccountSelectionStrategy"/>.</returns>
        public static IAsset AddNew(this OutputAssetCollection collection, string assetName, IAccountSelectionStrategy strategy, AssetCreationOptions options)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccount = strategy.SelectAccountForAsset();

            return collection.AddNew(assetName, storageAccount, options);
        }
Пример #7
0
        /// <summary>
        /// Returns a new empty <see cref="IAsset"/> within one selected storage account from <paramref name="storageAccountNames"/> based on the default <see cref="IAccountSelectionStrategy"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="assetName">The asset name.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new output asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <returns>A new empty <see cref="IAsset"/> within one selected storage account from the provided <see cref="IAccountSelectionStrategy"/>.</returns>
        public static IAsset AddNew(this OutputAssetCollection collection, string assetName, IAccountSelectionStrategy strategy, AssetCreationOptions options)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccount = strategy.SelectAccountForAsset();

            return(collection.AddNew(assetName, storageAccount, options));
        }
Пример #8
0
        public void ShouldCreateAssetWithRandomAccountSelectionStrategy()
        {
            IAccountSelectionStrategy selectionStrategy = RandomAccountSelectionStrategy.FromAccounts(this.context);

            this.asset = this.context.Assets.Create(Guid.NewGuid().ToString(), selectionStrategy, AssetCreationOptions.None);
        }
        /// <summary>
        /// Returns a <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.
        /// </summary>
        /// <param name="jobs">The <see cref="JobBaseCollection"/> instance.</param>
        /// <param name="mediaProcessorName">The name of the media processor.</param>
        /// <param name="taskConfiguration">The task configuration.</param>
        /// <param name="inputAsset">The input <see cref="IAsset"/> instance.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> instance used to pick the output asset storage account.</param>
        /// <param name="outputAssetName">The name of the output asset.</param>
        /// <param name="outputAssetOptions">The <see cref="AssetCreationOptions"/> of the output asset.</param>
        /// <returns>A <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.</returns>
        public static IJob CreateWithSingleTask(this JobBaseCollection jobs, string mediaProcessorName, string taskConfiguration, IAsset inputAsset, IAccountSelectionStrategy strategy, string outputAssetName, AssetCreationOptions outputAssetOptions)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string outputAssetStorageAccount = strategy.SelectAccountForAsset();

            return jobs.CreateWithSingleTask(mediaProcessorName, taskConfiguration, inputAsset, outputAssetName, outputAssetStorageAccount, outputAssetOptions);
        }
Пример #10
0
        /// <summary>
        /// Returns a <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="filePath">The path to the file to upload to the new <see cref="IAsset"/>.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <param name="uploadProgressChangedCallback">A callback to report the upload progress of the file.</param>
        /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.</returns>
        public static Task <IAsset> CreateFromFileAsync(this AssetBaseCollection assets, string filePath, IAccountSelectionStrategy strategy, AssetCreationOptions options, Action <IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback, CancellationToken cancellationToken)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccountName = strategy.SelectAccountForAsset();

            return(assets.CreateFromFileAsync(filePath, storageAccountName, options, uploadProgressChangedCallback, cancellationToken));
        }
Пример #11
0
        /// <summary>
        /// Returns a <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new empty <see cref="IAsset"/> asset within one selected storage account from <paramref name="storageAccountNames"/> based on the default <see cref="IAccountSelectionStrategy"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="assetName">The asset name.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <param name="token">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new empty <see cref="IAsset"/> within one selected storage account from the given <see cref="IAccountSelectionStrategy"/>.</returns>
        public static Task <IAsset> CreateAsync(this AssetBaseCollection assets, string assetName, IAccountSelectionStrategy strategy, AssetCreationOptions options, CancellationToken token)
        {
            if (assets == null)
            {
                throw new ArgumentNullException("assets");
            }

            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccountName = strategy.SelectAccountForAsset();

            return(assets.CreateAsync(assetName, storageAccountName, options, token));
        }
Пример #12
0
        /// <summary>
        /// Returns a new empty <see cref="IAsset"/> within one selected storage account from <paramref name="storageAccountNames"/> based on the default <see cref="IAccountSelectionStrategy"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="assetName">The asset name.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <returns>A new empty <see cref="IAsset"/> within one selected storage account from the provided <see cref="IAccountSelectionStrategy"/>.</returns>
        public static IAsset Create(this AssetBaseCollection assets, string assetName, IAccountSelectionStrategy strategy, AssetCreationOptions options)
        {
            if (assets == null)
            {
                throw new ArgumentNullException("assets");
            }

            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccountName = strategy.SelectAccountForAsset();

            return(assets.Create(assetName, storageAccountName, options));
        }
Пример #13
0
 /// <summary>
 /// Returns a new <see cref="IAsset"/> with the files in <paramref name="folderPath"/>.
 /// </summary>
 /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
 /// <param name="folderPath">The path to the folder with the files to upload to the new <see cref="IAsset"/>.</param>
 /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
 /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
 /// <param name="uploadProgressChangedCallback">A callback to report upload progress of the files.</param>
 /// <returns>A new <see cref="IAsset"/> with the files in <paramref name="folderPath"/>.</returns>
 public static IAsset CreateFromFolder(this AssetBaseCollection assets, string folderPath, IAccountSelectionStrategy strategy, AssetCreationOptions options, Action <IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback)
 {
     using (Task <IAsset> task = assets.CreateFromFolderAsync(folderPath, strategy, options, uploadProgressChangedCallback, CancellationToken.None))
     {
         return(task.Result);
     }
 }
Пример #14
0
        /// <summary>
        /// Returns a <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.
        /// </summary>
        /// <param name="jobs">The <see cref="JobBaseCollection"/> instance.</param>
        /// <param name="mediaProcessorName">The name of the media processor.</param>
        /// <param name="taskConfiguration">The task configuration.</param>
        /// <param name="inputAsset">The input <see cref="IAsset"/> instance.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> instance used to pick the output asset storage account.</param>
        /// <param name="outputAssetName">The name of the output asset.</param>
        /// <param name="outputAssetOptions">The <see cref="AssetCreationOptions"/> of the output asset.</param>
        /// <returns>A <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.</returns>
        public static IJob CreateWithSingleTask(this JobBaseCollection jobs, string mediaProcessorName, string taskConfiguration, IAsset inputAsset, IAccountSelectionStrategy strategy, string outputAssetName, AssetCreationOptions outputAssetOptions)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string outputAssetStorageAccount = strategy.SelectAccountForAsset();

            return(jobs.CreateWithSingleTask(mediaProcessorName, taskConfiguration, inputAsset, outputAssetName, outputAssetStorageAccount, outputAssetOptions));
        }
        /// <summary>
        /// Returns a <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.
        /// </summary>
        /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
        /// <param name="filePath">The path to the file to upload to the new <see cref="IAsset"/>.</param>
        /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
        /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
        /// <param name="uploadProgressChangedCallback">A callback to report the upload progress of the file.</param>
        /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task&lt;IAsset&gt;"/> instance for a new <see cref="IAsset"/> with the file in <paramref name="filePath"/>.</returns>
        public static Task<IAsset> CreateFromFileAsync(this AssetBaseCollection assets, string filePath, IAccountSelectionStrategy strategy, AssetCreationOptions options, Action<IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback, CancellationToken cancellationToken)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException("strategy");
            }

            string storageAccountName = strategy.SelectAccountForAsset();

            return assets.CreateFromFileAsync(filePath, storageAccountName, options, uploadProgressChangedCallback, cancellationToken);
        }
 /// <summary>
 /// Returns a new <see cref="IAsset"/> with the files in <paramref name="folderPath"/>.
 /// </summary>
 /// <param name="assets">The <see cref="AssetBaseCollection"/> instance.</param>
 /// <param name="folderPath">The path to the folder with the files to upload to the new <see cref="IAsset"/>.</param>
 /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> used to select a storage account for the new asset.</param>
 /// <param name="options">The <see cref="AssetCreationOptions"/>.</param>
 /// <param name="uploadProgressChangedCallback">A callback to report upload progress of the files.</param>
 /// <returns>A new <see cref="IAsset"/> with the files in <paramref name="folderPath"/>.</returns>
 public static IAsset CreateFromFolder(this AssetBaseCollection assets, string folderPath, IAccountSelectionStrategy strategy, AssetCreationOptions options, Action<IAssetFile, UploadProgressChangedEventArgs> uploadProgressChangedCallback)
 {
     using (Task<IAsset> task = assets.CreateFromFolderAsync(folderPath, strategy, options, uploadProgressChangedCallback, CancellationToken.None))
     {
         return task.Result;
     }
 }