/// <summary> /// A method is used to generate the destination URL. The file name in the URL is unique. /// </summary> /// <param name="destinationType">A parameter represents the destination URL type.</param> /// <returns>A return value represents the destination URL.</returns> protected string GetDestinationFileUrl(DestinationFileUrlType destinationType) { string urlPatternValueOfDestinationFile = string.Empty; string expectedPropertyName = string.Empty; switch (destinationType) { case DestinationFileUrlType.NormalDesLibraryOnDesSUT: { expectedPropertyName = "UrlPatternOfDesFileOnDestinationSUT"; break; } case DestinationFileUrlType.MWSLibraryOnDestinationSUT: { expectedPropertyName = "UrlPatternOfDesFileForMWSOnDestinationSUT"; break; } default: { throw new InvalidOperationException("The test suite only supports two destination type: [NormalDesLibraryOnDesSUT] and [MWSLibraryOnDestinationSUT]."); } } // Get match URL pattern. urlPatternValueOfDestinationFile = Common.GetConfigurationPropertyValue(expectedPropertyName, this.Site); if (urlPatternValueOfDestinationFile.IndexOf("{FileName}", StringComparison.OrdinalIgnoreCase) <= 0) { throw new InvalidOperationException(string.Format(@"The [{0}] property should contain the ""{fileName}"" placeholder.", expectedPropertyName)); } string fileNameValue = this.GetUniqueFileName(); string actualDestinationFileUrl = urlPatternValueOfDestinationFile.ToLower().Replace("{filename}", fileNameValue); // Verify the URL whether point to a file. FileUrlHelper.ValidateFileUrl(actualDestinationFileUrl); return(actualDestinationFileUrl); }
/// <summary> /// A method is used to generate the destination URL. The file name in the URL is unique. /// </summary> /// <param name="destinationType">A parameter represents the destination URL type.</param> /// <returns>A return value represents the destination URL.</returns> protected string GetDestinationFileUrl(DestinationFileUrlType destinationType) { string urlPatternValueOfDestinationFile = string.Empty; string expectedPropertyName = string.Empty; switch (destinationType) { case DestinationFileUrlType.NormalDesLibraryOnDesSUT: { expectedPropertyName = "UrlPatternOfDesFileOnDestinationSUT"; break; } case DestinationFileUrlType.MWSLibraryOnDestinationSUT: { expectedPropertyName = "UrlPatternOfDesFileForMWSOnDestinationSUT"; break; } default: { throw new InvalidOperationException("The test suite only supports two destination type: [NormalDesLibraryOnDesSUT] and [MWSLibraryOnDestinationSUT]."); } } // Get match URL pattern. urlPatternValueOfDestinationFile = Common.GetConfigurationPropertyValue(expectedPropertyName, this.Site); if (urlPatternValueOfDestinationFile.IndexOf("{FileName}", StringComparison.OrdinalIgnoreCase) <= 0) { throw new InvalidOperationException(string.Format(@"The [{0}] property should contain the ""{fileName}"" placeholder.", expectedPropertyName)); } string fileNameValue = this.GetUniqueFileName(); string actualDestinationFileUrl = urlPatternValueOfDestinationFile.ToLower().Replace("{filename}", fileNameValue); // Verify the URL whether point to a file. FileUrlHelper.ValidateFileUrl(actualDestinationFileUrl); return actualDestinationFileUrl; }