当前位置: 首页>>代码示例>>C#>>正文


C# MockFileSystem.AddDirectory方法代码示例

本文整理汇总了C#中System.IO.Abstractions.TestingHelpers.MockFileSystem.AddDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# MockFileSystem.AddDirectory方法的具体用法?C# MockFileSystem.AddDirectory怎么用?C# MockFileSystem.AddDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.Abstractions.TestingHelpers.MockFileSystem的用法示例。


在下文中一共展示了MockFileSystem.AddDirectory方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCleanRecursive

        public void TestCleanRecursive()
        {
            // Prepare the source and target directories and files.
            var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
            fileSystem.AddDirectory(@"C:\Source\SubDirectory");
            fileSystem.AddFile(@"C:\Target\SubDirectory\File.txt", new MockFileData("Data"));

            // Run the test.
            Cleaner.CleanResult result = Cleaner.Clean(fileSystem, @"C:\Target", @"C:\Source");

            // Check the results
            Assert.IsFalse(fileSystem.File.Exists(@"C:\Target\SubDirectory\File.txt"));
        }
开发者ID:rwakelam,项目名称:Flow,代码行数:13,代码来源:CleanerTests.cs

示例2: TestCleanByPattern

        public void TestCleanByPattern()
        {
            // Prepare the source and target directories and files.
            var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
            fileSystem.AddDirectory(@"C:\Source");
            fileSystem.AddFile(@"C:\Target\File.txt", new MockFileData("Data"));
            fileSystem.AddFile(@"C:\Target\File.doc", new MockFileData("Data"));

            // Run the test.
            Cleaner.CleanResult result = Cleaner.Clean(fileSystem, @"C:\Target", @"C:\Source", "*.txt");

            // Check the clean has worked properly.
            Assert.IsFalse(fileSystem.File.Exists(@"C:\Target\File.txt"));
            Assert.IsTrue(fileSystem.File.Exists(@"C:\Target\File.doc"));
        }
开发者ID:rwakelam,项目名称:Flow,代码行数:15,代码来源:CleanerTests.cs

示例3: TestPushDirectoryWhenSourceIsNotFound

 public void TestPushDirectoryWhenSourceIsNotFound()
 {
     var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
     fileSystem.AddDirectory(@"C:\Target");
     try
     {
         Pusher.PushDirectory(fileSystem, @"C:\Source", @"C:\Target");
         Assert.Fail("Exception not raised.");
     }
     catch (SyncDirectoryNotFoundException)
     {
     }
     catch
     {
         Assert.Fail("Wrong exception raised.");
     }
 }
开发者ID:rwakelam,项目名称:Flow,代码行数:17,代码来源:PusherTests.cs

示例4: TestCleanByAttributes

        public void TestCleanByAttributes()
        {
            // Prepare the source and target directories and files.
            var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
            fileSystem.AddDirectory(@"C:\Source");
            fileSystem.AddFile(@"C:\Target\File1.txt", new MockFileData("Data"));
            fileSystem.AddFile(@"C:\Target\File2.txt", new MockFileData("Data"));
            fileSystem.File.SetAttributes(@"C:\Target\File1.txt", FileAttributes.Normal);
            fileSystem.File.SetAttributes(@"C:\Target\File2.txt", FileAttributes.Hidden);

            // Run the test.
            Cleaner.CleanResult result = Cleaner.Clean(fileSystem, @"C:\Target", @"C:\Source", "*.*", FileAttributes.Normal);

            // Check the results
            Assert.IsFalse(fileSystem.File.Exists(@"C:\Target\File1.txt"));
            Assert.IsTrue(fileSystem.File.Exists(@"C:\Target\File2.txt"));
        }
开发者ID:rwakelam,项目名称:Flow,代码行数:17,代码来源:CleanerTests.cs

示例5: Should_Process_Less_Imports_With_Cleanup

        public void Should_Process_Less_Imports_With_Cleanup()
        {
            // arrange
            var filepath1 = @"c:\css\subfolder\style-dependency.less";
            var fileContent1 = "@brand_color: #4D926F;";
            var filepath2 = @"c:\css\style.less";
            var fileContent2 = "@import \"subfolder/style-dependency.less\"; @import \"foldertodelete/style-dependency2.less\"; @import \"foldertodelete/style-dependency3.less\"; @import \"../_site/style-dependency4.less\"; a { color: @brand_color; width: @width; height: @height; foo: @bar; }";
            var filepath3 = @"c:\css\foldertodelete\style-dependency2.less";
            var fileContent3 = "@width: 24px;";
            var filepath4 = @"c:\css\foldertodelete\style-dependency3.less";
            var fileContent4 = "@height: 24px;";
            var filepath5 = @"c:\_site\style-dependency4.less";
            var fileContent5 = "@bar: bold;";

            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { HtmlFilePath, new MockFileData(PageContent)},
                { filepath1, new MockFileData(fileContent1) },
                { filepath2, new MockFileData(fileContent2) },
                { filepath3, new MockFileData(fileContent3) },
                { filepath4, new MockFileData(fileContent4) },
                { filepath5, new MockFileData(fileContent5) },
                { @"c:\css\subfolder\anothersubfolder\anything.less", "@size: 12px;" }
            });
            fileSystem.AddDirectory(@"c:\css\emptysubfolder");

            var expectedOutput = @"a{color:#4d926f;width:24px;height:24px;foo:bold}";

            var minifier = new LessTransform(fileSystem);
            var context = new SiteContext { SourceFolder = @"C:\", OutputFolder = @"C:\_site" };
            context.Pages.Add(new NonProcessedPage { OutputFile = HtmlFilePath, Content = PageContent });
            context.Pages.Add(new NonProcessedPage { OutputFile = filepath1, Content = fileContent1, Filepath = filepath1 });
            context.Pages.Add(new NonProcessedPage { OutputFile = filepath2, Content = fileContent2, Filepath = filepath2 });
            context.Pages.Add(new NonProcessedPage { OutputFile = filepath3, Content = fileContent3, Filepath = filepath3 });
            context.Pages.Add(new NonProcessedPage { OutputFile = filepath4, Content = fileContent4, Filepath = filepath4 });
            context.Pages.Add(new NonProcessedPage { OutputFile = filepath5, Content = fileContent5, Filepath = filepath5 });

            // act
            minifier.Transform(context);

            // assert
            var minifiedFile = fileSystem.File.ReadAllText(@"c:\css\style.css", Encoding.UTF8);
            Assert.Equal(expectedOutput, minifiedFile);
            Assert.True(fileSystem.Directory.Exists(@"c:\css\emptysubfolder"));
            Assert.False(fileSystem.Directory.Exists(@"c:\css\foldertodelete"));
            Assert.False(fileSystem.File.Exists(@"c:\css\style.less"));
            Assert.True(fileSystem.Directory.Exists(@"c:\css\subfolder"));
            Assert.True(fileSystem.File.Exists(@"c:\css\subfolder\anothersubfolder\anything.less"));
            Assert.True(fileSystem.Directory.Exists(@"c:\_site"));
        }
开发者ID:impressive-mark,项目名称:pretzel,代码行数:50,代码来源:LessTransformTests.cs

示例6: TestSaveMaxEntries

        public void TestSaveMaxEntries()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { });
            fileSystem.AddDirectory(Database.DefaultConfigDir);
            var db = new Database(fileSystem);
            var fsp = new Provider("FileSystem");
            db.Providers.Add("FileSystem", fsp);
            fsp.Add(new Entry(@"c:\dir1\", 12, DateTime.Now, false));
            fsp.Add(new Entry(@"c:\dir1\file2", 34, DateTime.Now, true));
            db.Save(1);
            db.Load();

            Assert.AreEqual(1,db.Providers["FileSystem"].Entries.Count);
        }
开发者ID:kelleyma49,项目名称:fasdr,代码行数:14,代码来源:DatabaseTest.cs

示例7: TestGetEntries

        public void TestGetEntries()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { });
            fileSystem.AddDirectory(Database.DefaultConfigDir);
            var db = new Database(fileSystem);
            var fsp = new Provider("FileSystem");
            db.Providers.Add("FileSystem", fsp);
            var e1 = new Entry(@"c:\dir1\", 12, DateTime.Now, false);
            var e2 = new Entry(@"c:\dir1\file2", 34, DateTime.Now, true);
            fsp.Add(e1);
            fsp.Add(e2);

            Entry[] entries = null;
            Assert.IsTrue(db.GetEntries("FileSystem", out entries));
            Assert.AreEqual(e2, entries[0]);
            Assert.AreEqual(e1, entries[1]);
        }
开发者ID:kelleyma49,项目名称:fasdr,代码行数:17,代码来源:DatabaseTest.cs

示例8: TestConfigSimpleDatabase

        public void TestConfigSimpleDatabase()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> {});
            fileSystem.AddDirectory (Database.DefaultConfigDir);

            var db = new Database(fileSystem);
            var fsp = new Provider("FileSystem");
            db.Providers.Add ("FileSystem", fsp);
            var e1 = new Entry (@"c:\dir1\", 12, DateTime.Now, false);
            var e2 = new Entry (@"c:\dir1\file2", 34, DateTime.Now, true);

            fsp.Add(e1);
            fsp.Add(e2);
            db.Save(100);

            var fsFileName = System.IO.Path.Combine (Database.DefaultConfigDir,$"{Database.ConfigFilePrefix}.FileSystem.txt");

            Assert.IsTrue(fileSystem.FileExists(FileSystemConfigPath));
            Assert.AreEqual(
                string.Join(Environment.NewLine,e1.ToString(),e2.ToString(),""),
                fileSystem.File.ReadAllText(fsFileName));
        }
开发者ID:kelleyma49,项目名称:fasdr,代码行数:22,代码来源:DatabaseTest.cs

示例9: TestConfigLoadFileNotFound

        public void TestConfigLoadFileNotFound()
        {
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(Database.DefaultConfigDir);

            var db = new Database(fileSystem);
            db.Load();
        }
开发者ID:kelleyma49,项目名称:fasdr,代码行数:8,代码来源:DatabaseTest.cs

示例10: TestPushDirectoryWhenSourcePathIsNull

 public void TestPushDirectoryWhenSourcePathIsNull()
 {
     var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
     fileSystem.AddDirectory(@"C:\Target");
     try
     {
         Pusher.PushDirectory(fileSystem, null, @"C:\Target");
         Assert.Fail("Exception not raised.");
     }
     catch (ArgumentNullException)
     {
     }
     catch
     {
         Assert.Fail("Wrong exception raised.");
     }
 }
开发者ID:rwakelam,项目名称:Flow,代码行数:17,代码来源:PusherTests.cs

示例11: Setup

        public void Setup()
        {
            _mocker = new AutoMoqer();

            // GetMock of the abstract class before create to prevent automoq bugs
            _mocker.GetMock<FileSystemWatcherBase>();

            _fileSystem = new MockFileSystem();
            _fileSystem.AddDirectory(BaseDirectory);
            _mocker.SetInstance<IFileSystem>(_fileSystem);
        }
开发者ID:KallDrexx,项目名称:Backplan,代码行数:11,代码来源:DirectoryCrawlerTests.cs

示例12: TestCleanResult

        public void TestCleanResult()
        {
            // Prepare the source and target directories and files.
            var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
            fileSystem.AddFile(@"C:\Source\File1.txt", new MockFileData("Data"));
            fileSystem.AddFile(@"C:\Target\File1.txt", new MockFileData("Data"));
            fileSystem.AddFile(@"C:\Target\File2.txt", new MockFileData("Data"));
            fileSystem.AddDirectory(@"C:\Source\SubDirectory");
            fileSystem.AddDirectory(@"C:\Target\SubDirectory");

            // Run the test.
            var result = Cleaner.Clean(fileSystem, @"C:\Target", @"C:\Source");

            // Check the result.
            Assert.AreEqual(1, result.MatchedFiles.Count);
            Assert.AreEqual("File1.txt", result.MatchedFiles[0]);
            Assert.AreEqual(1, result.DeletedEntries.Count);
            Assert.AreEqual("File2.txt", result.DeletedEntries[0]);
            Assert.AreEqual(0, result.FailedEntries.Count);
            // TODO:: figure out how to spoof a fail an entry?
            Assert.AreEqual(1, result.DirectoryResults.Count);
        }
开发者ID:rwakelam,项目名称:Flow,代码行数:22,代码来源:CleanerTests.cs

示例13: TestCleanWhenSourceIsNotFound

 public void TestCleanWhenSourceIsNotFound()
 {
     var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem();
     fileSystem.AddDirectory(@"C:\Target");
     try
     {
         Cleaner.Clean(fileSystem, @"C:\Target", @"C:\Source");
         Assert.Fail("Exception not raised.");
     }
     catch (SyncDirectoryNotFoundException)//TODO:: replace with straight System.IO.Exception?
     { }
     catch
     {
         Assert.Fail("Wrong exception raised.");
     }
 }
开发者ID:rwakelam,项目名称:Flow,代码行数:16,代码来源:CleanerTests.cs


注:本文中的System.IO.Abstractions.TestingHelpers.MockFileSystem.AddDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。