Beispiel #1
0
        public void ExpandFullyQualified()
        {
            var fileName     = Path.Combine(Path.GetPathRoot(Environment.CurrentDirectory), "test", "demo.txt");
            var expandedPath = ConfigurationUtilities.ExpandConfigFileName(fileName, null);

            Assert.IsTrue(string.Equals(fileName, expandedPath, StringComparison.Ordinal), "Expanded directory path was incorrect");
        }
Beispiel #2
0
        public void ExpandFileName(bool offRoot, string directory, string fileName, params string[] pathElements)
        {
            var constructedDirectoryPathElements = new List <string>();

            if (offRoot)
            {
                constructedDirectoryPathElements.Add(Path.GetPathRoot(Environment.CurrentDirectory));
            }
            if ((pathElements?.Count() ?? 0) > 0)
            {
                constructedDirectoryPathElements.AddRange(pathElements);
            }

            var constructedDirectoryPath = Path.Combine(constructedDirectoryPathElements.ToArray());

            if (offRoot)
            {
                Path.Combine(Path.GetPathRoot(Environment.CurrentDirectory), directory);
            }


            var expectedQualifiedName = offRoot ? Path.Combine(constructedDirectoryPath, fileName) : Path.Combine(Environment.CurrentDirectory, constructedDirectoryPath, fileName);


            var expandedPath = ConfigurationUtilities.ExpandConfigFileName(fileName, constructedDirectoryPath);

            Assert.IsTrue(string.Equals(expectedQualifiedName, expandedPath, StringComparison.Ordinal), "Expanded directory path was incorrect");
        }