Пример #1
0
        public void Init()
        {
            path       = Path.GetFullPath(path);
            parentPath = Path.GetFullPath(parentPath);
            testPath   = Path.GetFullPath(testPath);

            if (!ListingService.Exists(path))
            {
                ListingService.Create("Test", parentPath, Data.Listing.ListingTypeOption.Directory, Data.Listing.DuplicateListingActionOption.NoAction);
            }

            var deleteFiles = ListingService.GetListingByDirectory(path, true, true);

            foreach (var f in deleteFiles)
            {
                ListingService.Delete(f.FullFilePath);
            }

            var testFiles = ListingService.GetListingByDirectory(testPath, false, true);

            foreach (var f in testFiles)
            {
                ListingService.Copy(f.FullFilePath, path + @"\" + f.Name);
            }
        }
Пример #2
0
        public void Copy()
        {
            var p = ListingService.Create("testfile-4.txt", path, ListingTypeOption.File, DuplicateListingActionOption.NoAction);

            // No action - file does not exist.
            var f = ListingService.Copy(path + @"\testfile-4.txt", path + @"\testfile-42.txt", DuplicateListingActionOption.NoAction);

            Assert.AreEqual(f, path + @"\testfile-42.txt");
            Assert.AreEqual(ListingService.Exists(path + @"\testfile-42.txt"), true);

            // Illegal characters.
            try
            {
                f = ListingService.Copy(path + @"\testfile-4|.txt", path + @"\testfile-42|.txt", DuplicateListingActionOption.NoAction);
                Assert.Fail();
            }
            catch (ByteTurnNotSupportedException byteturnex)
            {
                Assert.AreEqual(typeof(ByteTurnNotSupportedException), byteturnex.GetType());
            }

            // No action - file exists.
            try
            {
                f = ListingService.Copy(path + @"\testfile-4.txt", path + @"\testfile-42.txt", DuplicateListingActionOption.NoAction);
                Assert.Fail();
            }
            catch (ByteTurnExistsException byteturnex)
            {
                Assert.AreEqual(typeof(ByteTurnExistsException), byteturnex.GetType());
            }

            // Overwrite
            f = ListingService.Copy(path + @"\testfile-4.txt", path + @"\testfile-42.txt", DuplicateListingActionOption.Overwrite);
            Assert.AreEqual(f, path + @"\testfile-42.txt");
            Assert.AreEqual(ListingService.Exists(path + @"\testfile-42.txt"), true);

            // Append number
            f = ListingService.Copy(path + @"\testfile-4.txt", path + @"\testfile-42.txt", DuplicateListingActionOption.AppendNumber);
            Assert.AreEqual(f, path + @"\(1) testfile-42.txt");
            Assert.AreEqual(ListingService.Exists(path + @"\(1) testfile-42.txt"), true);
        }