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


C# IFileSystem.Exist方法代码示例

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


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

示例1: ShouldSetSystraySwitch

        public void ShouldSetSystraySwitch([Frozen] IAdvProcessRunner runner,
             IFileSystem fileSystem, AppPathBasedIISExpressRunner sut)
        {
            var settings = new AppPathBasedIISExpressSettings(@"c:\MyApp") { EnableSystemTray = false };
            fileSystem.Exist(settings.AppPath).Returns(true);
            sut.StartServer(settings);

            runner.Received()
                .Start(Arg.Any<FilePath>(),
                    Arg.Is<AdvProcessSettings>(p => p.Arguments.Render() == "/path:\"c:/MyApp\" /systray:false"));
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:11,代码来源:AppPathBasedIISExpressRunnerTests.cs

示例2: ShouldThrowIfAppPathDoesNotExist

        public void ShouldThrowIfAppPathDoesNotExist([Frozen] IAdvProcessRunner runner,
            IFileSystem fileSystem,
            AppPathBasedIISExpressRunner sut)
        {
            var settings = new AppPathBasedIISExpressSettings(@"c:\MyApp");

            fileSystem.Exist(settings.AppPath).Returns(false);

            sut.Invoking(s => s.StartServer(settings)).ShouldThrow<CakeException>();

            runner.DidNotReceiveWithAnyArgs()
                .Start(null, null);
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:13,代码来源:AppPathBasedIISExpressRunnerTests.cs

示例3: ShouldSetAppPathSwitchFromAbsolutePath

        public void ShouldSetAppPathSwitchFromAbsolutePath(
            [Frozen] ICakeEnvironment environment,
            IFileSystem fileSystem, [Frozen] IAdvProcessRunner runner,
            AppPathBasedIISExpressRunner sut)
        {
            var settings = new AppPathBasedIISExpressSettings(@"c:\MyApp");
            
            fileSystem.Exist(Arg.Is(settings.AppPath)).Returns(true);

            sut.StartServer(settings);

            runner.Received()
                .Start(Arg.Any<FilePath>(),
                    Arg.Is<AdvProcessSettings>(
                        p =>
                            p.Arguments.Render() ==
                            "/path:\"c:/MyApp\""));
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:18,代码来源:AppPathBasedIISExpressRunnerTests.cs

示例4: ShouldSetAppPathSwitchFromRelativeFilePath

        public void ShouldSetAppPathSwitchFromRelativeFilePath(
            [Frozen] ICakeEnvironment environment,
            IFileSystem fileSystem, [Frozen] IAdvProcessRunner runner,
            AppPathBasedIISExpressRunner sut)
        {
            environment.WorkingDirectory.Returns("c:/build/MyWorkingDirectory");

            var settings = new AppPathBasedIISExpressSettings(@"..\MyApp");

            fileSystem.Exist(Arg.Is<DirectoryPath>(x => x.FullPath == "c:/build/MyApp")).Returns(true);

            sut.StartServer(settings);

            runner.Received()
                .Start(Arg.Any<FilePath>(),
                    Arg.Is<AdvProcessSettings>(
                        p =>
                            p.Arguments.Render() ==
                            "/path:\"c:/build/MyApp\""));
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:20,代码来源:AppPathBasedIISExpressRunnerTests.cs

示例5: ShouldSetConfigFileSwitchFromRelativeFilePath

        public void ShouldSetConfigFileSwitchFromRelativeFilePath(
            [Frozen] ICakeEnvironment environment,
            IFileSystem fileSystem, [Frozen] IAdvProcessRunner runner,
            ConfigBasedIISExpressRunner sut)
        {
            environment.WorkingDirectory.Returns("c:/MyWorkingDirectory");
            var settings = new ConfigBasedIISExpressSettings
            {
                ConfigFilePath = FilePath.FromString("applicationhost.config")
            };

            fileSystem.Exist(
                Arg.Is<FilePath>(
                    f =>
                        f.FullPath.Equals("c:/MyWorkingDirectory/applicationhost.config",
                            StringComparison.OrdinalIgnoreCase))).Returns(true);

            sut.StartServer(settings);

            runner.Received()
                .Start(Arg.Any<FilePath>(),
                    Arg.Is<AdvProcessSettings>(
                        p =>
                            p.Arguments.Render() ==
                            "/config:\"c:/MyWorkingDirectory/applicationhost.config\""));
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:26,代码来源:ConfigBasedIISExpressRunnerTests.cs

示例6: ShouldThrowWhenConfigFileDoesNotExist

        public void ShouldThrowWhenConfigFileDoesNotExist([Frozen] ICakeEnvironment environment,
            IFileSystem fileSystem, [Frozen] IAdvProcessRunner runner,
            ConfigBasedIISExpressRunner sut)
        {
            environment.WorkingDirectory.Returns("c:/MyWorkingDirectory");

            var settings = new ConfigBasedIISExpressSettings
            {
                ConfigFilePath =
                    FilePath.FromString(@"c:\someOtherDirectory\applicationhost.config")
            };

            fileSystem.Exist(
                Arg.Is<FilePath>(
                    f =>
                        f.FullPath.Equals(settings.ConfigFilePath.FullPath,
                            StringComparison.OrdinalIgnoreCase))).Returns(false);

            sut.Invoking(s => s.StartServer(settings)).ShouldThrow<CakeException>();

            runner.DidNotReceiveWithAnyArgs().Start(null, null);
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:22,代码来源:ConfigBasedIISExpressRunnerTests.cs

示例7: ShouldWaitUntilIISExpressServerIsStarted

        public void ShouldWaitUntilIISExpressServerIsStarted([Frozen] ICakeLog log,
            [Frozen] IAdvProcess process, IFileSystem fileSystem,
            [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry,
            AppPathBasedIISExpressRunner sut)
        {
            var simulatedStandardOutput = new[]
            {"1", "2", "3", "4", "IIS Express is running.", "5"};

            // hooking into the logging call that occurs previous to waiting is the only place I could 
            // think of to send in simulated output to signal IIS Express has started.
            log.When(
                l =>
                    l.Write(Arg.Any<Verbosity>(), Arg.Any<LogLevel>(),
                        "Waiting for IIS Express to start (timeout: {0}ms)", Arg.Any<object[]>()))
                .Do(ci =>
                {
                    foreach (var s in simulatedStandardOutput)
                    {
                        process.OutputDataReceived += Raise.EventWith(process,
                            new ProcessOutputReceivedEventArgs(s));
                    }
                });

            processRunner.Start(Arg.Any<FilePath>(), Arg.Any<AdvProcessSettings>())
                .Returns(ci => process);

            var settings = new AppPathBasedIISExpressSettings(@"c:\MyApp") {WaitForStartup = 1000};
            fileSystem.Exist(settings.AppPath).Returns(true);

            sut.StartServer(settings);

            log.Received()
                .Write(Verbosity.Normal, LogLevel.Information,
                    Arg.Is<string>(s => s.StartsWith("IIS Express is running")), Arg.Any<object[]>());
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:35,代码来源:AppPathBasedIISExpressRunnerTests.cs

示例8: ShouldThrowWhenIISExpressProcessWritesToErrorStream

        public void ShouldThrowWhenIISExpressProcessWritesToErrorStream([Frozen] IAdvProcess process,
            IFileSystem fileSystem,
            [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry,
            AppPathBasedIISExpressRunner sut)
        {
            processRunner.Start(Arg.Any<FilePath>(), Arg.Any<AdvProcessSettings>()).Returns(process);

            var settings = new AppPathBasedIISExpressSettings(@"c:\MyApp");
            fileSystem.Exist(settings.AppPath).Returns(true);

            sut.StartServer(settings);

            process.Invoking(
                           p =>
                               p.ErrorDataReceived +=
                                   Raise.EventWith(
                                       new ProcessOutputReceivedEventArgs("some dummy error data received")))
                           .ShouldThrow<CakeException>()
                           .WithMessage(
                               "IIS Express returned the following error message: 'some dummy error data received'");
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:21,代码来源:AppPathBasedIISExpressRunnerTests.cs

示例9: ShouldSetClrVersionSwitch

        public void ShouldSetClrVersionSwitch([Frozen] IAdvProcessRunner runner,
             IFileSystem fileSystem, AppPathBasedIISExpressRunner sut)
        {
            var settings = new AppPathBasedIISExpressSettings(@"c:\MyApp") { ClrVersion = ClrVersion.Version20 };
            fileSystem.Exist(settings.AppPath).Returns(true);

            sut.StartServer(settings);

            runner.Received()
                .Start(Arg.Any<FilePath>(),
                    Arg.Is<AdvProcessSettings>(
                        p => p.Arguments.Render() == "/path:\"c:/MyApp\" /clr:v2.0"));
        }
开发者ID:jrnail23,项目名称:Cake.IISExpress,代码行数:13,代码来源:AppPathBasedIISExpressRunnerTests.cs


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