Ejemplo n.º 1
0
 public void HandleDuplicateName() {
     var @base = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "temp" + Randomizer.RandomString(10) + "/"));
     if (@base.Exists==false)
         @base.Create();
     try {
         var org_file = @base.PathCombineFile(Randomizer.RandomString(10) + ".potato");
         var file = org_file.HandlePossibleDuplicate();
         Assert.AreEqual(org_file.FullName, file.FullName);
         File.WriteAllText(file.FullName, "");
         file = org_file.HandlePossibleDuplicate();
         Assert.IsTrue(file.FullName.EndsWith($"{org_file.GetFileNameWithoutExtension()} (1){org_file.Extension}"));
     } finally {
         @base.Delete(true);
     }
 }
        public void PathCombine()
        {
            // Type
            var @this = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

            string path1 = "Fizz";
            string path2 = "Buzz";

            // Exemples
            FileInfo result = @this.PathCombineFile(path1, path2); // Combine path1 and path2 with the DirectoryInfo

            // Unit Test
            var expected = new FileInfo(Path.Combine(@this.FullName, path1, path2));
            Assert.AreEqual(expected.FullName, result.FullName);
        }