public void AddChunks_AddTwoWebChunks_NoTerminatingSlash()
        {
            var path     = @"https://files.example/Alice";
            var pathInfo = new PathInfo(path);

            pathInfo.AddChunks(false, "Documents", "Work");

            var expected = @"https://files.example/Alice/Documents/Work";
            var actual   = pathInfo.FilePath;

            Assert.AreEqual(expected, actual);
        }
        public void AddChunks_AddTwoLocalChunks_NoTerminatingSlash()
        {
            var path     = @"C:\Users\Alice\";
            var pathInfo = new PathInfo(path);

            pathInfo.AddChunks(false, "Documents", "Work");

            var expected = @"C:\Users\Alice\Documents\Work";
            var actual   = pathInfo.FilePath;

            Assert.AreEqual(expected, actual);
        }
        public void AddChunkAnd_SetFileName_WebPath()
        {
            var originalPath = @"https://files.example/";
            var target       = new PathInfo(originalPath);

            target.AddChunks(true, "User");
            target.SetFileName("MyImage.png");

            var expected = @"https://files.example/User/MyImage.png";
            var actual   = target.FilePath;

            Assert.AreEqual(expected, actual);
        }
        public void AddChunkAnd_SetFileName_LocalPath()
        {
            var originalPath = @"C:\Files\";
            var target       = new PathInfo(originalPath);

            target.AddChunks(true, "User");
            target.SetFileName("MyImage.png");

            var expected = @"C:\Files\User\MyImage.png";
            var actual   = target.FilePath;

            Assert.AreEqual(expected, actual);
        }
        public void AddChunkAnd_SetFileName_ForgottenSeparators_WebPath()
        {
            //"Forget" the terminating slash in originalPath:
            var originalPath = @"https://files.example";
            var target       = new PathInfo(originalPath);

            //False, to "forget" to add intermediate separator
            target.AddChunks(false, "User");
            // It's now "https://files.example/User" which does not "appear" to be a directory, but a file

            // "MyImage.png" will overwrite "User"
            target.SetFileName("MyImage.png");

            var expected = @"https://files.example/MyImage.png";
            var actual   = target.FilePath;

            Assert.AreEqual(expected, actual);
        }
        public void ExampleUsageForReadme()
        {
            string myPath   = @"C:\Users\Coder\Documents\Code\Project\File.cs";
            var    pathInfo = new PathInfo(myPath);

            pathInfo.ConformSeparatorTo('/');

            //Remove the filename (strip it back to directory only)
            pathInfo.SetFileName("");

            pathInfo.AddChunks(true, "src", "Controllers");
            pathInfo.SetFileName("FileNameController.cs");

            Assert.AreEqual(@"C:\Users\Coder\Documents\Code\Project\src\Controllers\FileNameController.cs", pathInfo.FilePath);

            string remotePath = "https://files.example/Coder/Documents/";
            string newPath    = PathMatcher.Resituate(pathInfo.FilePath, remotePath);

            string expected = "https://files.example/Coder/Documents/Code/Project/src/Controllers/FileNameController.cs";

            Assert.AreEqual(expected, newPath);
        }