Пример #1
0
        public void WikiFileUniquePathTest()
        {
            var root       = Path.GetTempPath();
            var wikiFile   = new WikiFile(root, "TestPage");
            var wikiFolder = Path.Combine(root, "files\\testResults\\TestPage");

            Directory.CreateDirectory(wikiFolder);
            var dir = new DirectoryInfo(wikiFolder);

            foreach (var file in dir.EnumerateFiles("*test*.rik"))
            {
                file.Delete();
            }
            var a = wikiFile.UniquePathFor("test.rik", 0);

            Assert.IsTrue(a.EndsWith("000101010000000000_test_1.rik", StringComparison.Ordinal), "test 1");
            File.Create(a).Close();
            var b = wikiFile.UniquePathFor("test.rik", 0);

            Assert.IsTrue(b.EndsWith("000101010000000000_test_2.rik", StringComparison.Ordinal), "test 2");
            Assert.IsTrue(wikiFile.UniquePathFor(string.Empty, 0).EndsWith("000101010000000000__1", StringComparison.Ordinal), "test 3");
            Assert.IsTrue(wikiFile.UniquePathFor(null, 0).EndsWith("000101010000000000__1", StringComparison.Ordinal), "test 4");
            Assert.IsTrue(wikiFile.UniquePathFor(".rik", 0).EndsWith("000101010000000000__1.rik", StringComparison.Ordinal), "test 5");
            File.Delete(a);
        }