/// <summary>
        /// Creates a new EmbeddedResourceFileSource instance.
        /// </summary>
        /// <param name="assembly">The assembly containing the embedded resource file.</param>
        /// <param name="path">
        /// <para>
        /// The path to the embedded resource without the file name. An embedded resource
        /// path is usually formed from the default assembly namespace and the folder
        /// path, delimited by '.' (period) e.g. "Cofoundry.Domain.ExampleParentFolder.ExampleChildFolder"
        /// </para>
        /// <para>
        /// Note that special characters such as spaces and dashes are replaced by underscores
        /// in embedded resource names, however this conversion is done automatically for you
        /// during construction.
        /// </para>
        /// </param>
        /// <param name="fileName">
        /// <para>
        /// The file name including file extensions e.g. "myFile.jpg".
        /// </para>
        /// </param>
        public EmbeddedResourceFileSource(
            Assembly assembly,
            string path,
            string fileName
            )
        {
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentEmptyException(nameof(path));
            }

            if (fileName == null)
            {
                throw new ArgumentNullException(nameof(fileName));
            }
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentEmptyException(nameof(fileName));
            }

            Assembly = assembly;
            FileName = fileName;
            FullPath = EmbeddedResourcePathFormatter.CleanPath(path) + "." + fileName;
        }
Esempio n. 2
0
        public void CleanPath_WhenSuperfluousDelimiters_Removes(string input, string expected)
        {
            var result = EmbeddedResourcePathFormatter.CleanPath(input);

            Assert.Equal(expected, result);
        }
Esempio n. 3
0
        public void CleanPath_WhenInvalidChars_Corrects(string input, string expected)
        {
            var result = EmbeddedResourcePathFormatter.CleanPath(input);

            Assert.Equal(expected, result);
        }