Пример #1
0
 public void JonPath_Simple(string parent, string child, string expected)
 {
     AssertAll.Of(
         () => Assert.That(BPath.JoinPath(parent, child), Is.EqualTo(expected)),
         () => Assert.That(BPath.JoinPath(new[] { parent, child }), Is.EqualTo(expected))
         );
 }
Пример #2
0
        public void File_To_Uri(string file)
        {
            var fi = new FileInfo(file);

            AssertAll.Of(
                () => Assert.That(fi.ToUri(), Has.Property(nameof(Uri.IsFile)).True),
                () => Assert.That(fi.ToUri().AbsolutePath, Is.EqualTo(BPath.NormalizeSeparators(fi.FullName)))
                );
        }
Пример #3
0
        public void Directory_To_Uri(string directory)
        {
            var di = new DirectoryInfo(directory);

            AssertAll.Of(
                () => Assert.That(di.ToUri(), Has.Property(nameof(Uri.IsFile)).True),
                () => Assert.That(
                    di.ToUri().AbsolutePath,
                    Is.EqualTo(
                        BPath.NormalizeSeparators(BPath.EnsureTrailingSeparator(di.FullName))
                        )
                    )
                );
        }
Пример #4
0
 public void IsValidFilename(string path, Should pathShould, Should fileNameShould)
 {
     AssertAll.Of(
         () => AssertAll.Of(
             "Path Validation",
             () => Assert.That(BPath.IsValidPath(path), Is.EqualTo(pathShould == Pass)),
             () => Assert.That(BPath.ValidatePath(path), Has.Property(nameof(Failable.Failed)).EqualTo(pathShould == Fail))
             ),
         () => AssertAll.Of(
             "FileName Validation",
             () => Assert.That(BPath.IsValidFileName(path), Is.EqualTo(fileNameShould == Pass)),
             () => Assert.That(BPath.ValidateFileName(path), Has.Property(nameof(Failable.Failed)).EqualTo(fileNameShould == Fail))
             )
         );
 }
Пример #5
0
 public void GetExtensions(string path, string expectedFileName, params string[] expectedExtensions)
 {
     AssertAll.Of(
         () => Console.WriteLine($"{nameof(GetExtensions)}: {BPath.GetExtensions(path).Prettify()}"),
         () => Assert.That(BPath.GetExtensions(path), Is.EqualTo(expectedExtensions)),
         () => Assert.That(BPath.GetFullExtension(path), Is.EqualTo(expectedExtensions.JoinString())),
         () => Assert.That(BPath.GetFileNameWithoutExtensions(path), Is.EqualTo(expectedFileName)),
         () => AssertAll.Of(
             $"{nameof(FileSystemInfo)} extensions",
             () => Console.WriteLine($"{nameof(FileInfo)}: {new FileInfo(path)}, {new FileInfo(path).Name}, {new FileInfo(path).FullName}"),
             () => Assert.That(new FileInfo(path).Extensions(), Is.EqualTo(expectedExtensions)),
             () => Assert.That(new FileInfo(path).FullExtension(), Is.EqualTo(expectedExtensions.JoinString())),
             () => Assert.That(new FileInfo(path).FileNameWithoutExtensions(), Is.EqualTo(expectedFileName))
             )
         );
 }
Пример #6
0
 public void Fix_Separators(string input, string expected_trail, string expected_strip)
 {
     Assert.That(BPath.EnsureTrailingSeparator(input), Is.EqualTo(expected_trail));
 }
Пример #7
0
 public void JoinPath(string expectedPath, params string[] parts)
 {
     Console.WriteLine(@"\n: " + string.IsNullOrWhiteSpace("\n"));
     Console.WriteLine(@"\t: " + string.IsNullOrWhiteSpace("\t"));
     Assert.That(BPath.JoinPath(parts), Is.EqualTo(expectedPath));
 }