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


C# MockFileSystem.FileExists方法代码示例

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


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

示例1: TestConfigCanMerge

        public void TestConfigCanMerge()
        {
            var now = DateTime.Now;
            var mockE1 = new Entry (@"c:\dir2\", 1, now, false);
            var mockE2 = new Entry(@"c:\dir2\file3",10,now,true);
            var mockE3 = new Entry(@"c:\dir3\file1",101,now,true);
            var mockContent = string.Join (Environment.NewLine,
                mockE1.ToString (),
                mockE2.ToString (),
                mockE3.ToString ());

            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> {
                {   FileSystemConfigPath, new MockFileData(mockContent) }
            });

            var db = new Database(fileSystem);
            var fsp = new Provider("FileSystem");
            db.Providers.Add ("FileSystem", fsp);
            now = now.AddSeconds (1);
            var e1 = new Entry (@"c:\dir1\", 12, now, false);
            var e2 = new Entry (@"c:\dir1\file2", 34, now, true);
            var e3 = new Entry(@"c:\dir2\file3",11,now,true);
            var e4 = new Entry(@"c:\dir3\file1",11,now,true);

            fsp.Add(e1);
            fsp.Add(e2);
            fsp.Add(e3);
            fsp.Add(e4);
            Assert.IsTrue(fsp.Remove(e4.FullPath));
            db.Save(100);

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

            Assert.IsTrue(fileSystem.FileExists(FileSystemConfigPath));
            var configContent = fileSystem.File.ReadAllText (fsFileName);
            StringAssert.Contains (e1 + Environment.NewLine, configContent);
            StringAssert.Contains (e2 + Environment.NewLine, configContent);
            StringAssert.Contains (e3 + Environment.NewLine, configContent);
            StringAssert.Contains (mockE1 + Environment.NewLine, configContent);
            StringAssert.DoesNotContain (mockE2 + Environment.NewLine, configContent);
            StringAssert.DoesNotContain (mockE3 + Environment.NewLine, configContent);
            StringAssert.DoesNotContain(e4 + Environment.NewLine, configContent);
        }
开发者ID:kelleyma49,项目名称:fasdr,代码行数:43,代码来源:DatabaseTest.cs

示例2: TestConfigSaveNoFiles

        public void TestConfigSaveNoFiles()
        {
            var fileSystem = new MockFileSystem();

            var db = new Database(fileSystem);
            db.Save(100);

            Assert.IsTrue(!fileSystem.FileExists(FileSystemConfigPath));
        }
开发者ID:kelleyma49,项目名称:fasdr,代码行数:9,代码来源:DatabaseTest.cs

示例3: 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

示例4: UpdateFileSystem

 private static void UpdateFileSystem(string path, string fileContent, MockFileSystem fileSystem)
 {
     if(!fileSystem.FileExists(path))
         fileSystem.AddFile(path, new MockFileData(fileContent));
     Assert.True(fileSystem.FileExists(path), "File {0} doesn't exist but it should.", path);
 }
开发者ID:BraveSirAndrew,项目名称:DualityScripting,代码行数:6,代码来源:ScriptResourceEventsTests.cs


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