public void ShouldTimeoutWhenIISExpressTakesLongerThanSpecifiedWaitTimeToStart( [Frozen] ICakeLog log, [Frozen] IAdvProcess process, [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry, ConfigBasedIISExpressRunner 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 => { Thread.Sleep(100); 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 ConfigBasedIISExpressSettings { WaitForStartup = 50 }; sut.Invoking(s => s.StartServer(settings)) .ShouldThrow <CakeException>() .WithMessage("Timed out while waiting for IIS Express to start. (timeout: 50ms)"); }
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\"")); }
public void ShouldNotSetAnySwitchesByDefault([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings(); sut.StartServer(settings); runner.Received() .Start(Arg.Any <FilePath>(), Arg.Is <AdvProcessSettings>(p => p.Arguments.Render() == "")); }
public void ShouldThrowWhenBothSiteIdAndSiteNameAreSet([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { SiteIdToLaunch = 53, SiteNameToLaunch = "MySite" }; sut.Invoking(s => s.StartServer(settings)).ShouldThrow<InvalidOperationException>(); }
public void ShouldSetSiteIdSwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { SiteIdToLaunch = 53 }; sut.StartServer(settings); runner.Received() .Start(Arg.Any<FilePath>(), Arg.Is<AdvProcessSettings>(p => p.Arguments.Render() == "/siteid:53")); }
public void ShouldSetAppPoolSwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { AppPoolToLaunch = "MyAppPool" }; sut.StartServer(settings); runner.Received() .Start(Arg.Any<FilePath>(), Arg.Is<AdvProcessSettings>(p => p.Arguments.Render() == "/apppool:MyAppPool")); }
public void ShouldNotSetAnySwitchesByDefault([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings(); sut.StartServer(settings); runner.Received() .Start(Arg.Any<FilePath>(), Arg.Is<AdvProcessSettings>(p => p.Arguments.Render() == "")); }
public void ShouldThrowWhenBothSiteIdAndSiteNameAreSet([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { SiteIdToLaunch = 53, SiteNameToLaunch = "MySite" }; sut.Invoking(s => s.StartServer(settings)).ShouldThrow <InvalidOperationException>(); }
public void ShouldSetTraceSwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { TraceLevel = TraceLevel.Warning }; sut.StartServer(settings); runner.Received() .Start(Arg.Any <FilePath>(), Arg.Is <AdvProcessSettings>(p => p.Arguments.Render() == "/trace:warning")); }
public void ShouldSetAppPoolSwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { AppPoolToLaunch = "MyAppPool" }; sut.StartServer(settings); runner.Received() .Start(Arg.Any <FilePath>(), Arg.Is <AdvProcessSettings>(p => p.Arguments.Render() == "/apppool:MyAppPool")); }
public void ShouldSetSiteIdSwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { SiteIdToLaunch = 53 }; sut.StartServer(settings); runner.Received() .Start(Arg.Any <FilePath>(), Arg.Is <AdvProcessSettings>(p => p.Arguments.Render() == "/siteid:53")); }
public void ShouldSetSystraySwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { EnableSystemTray = false }; sut.StartServer(settings); runner.Received() .Start(Arg.Any <FilePath>(), Arg.Is <AdvProcessSettings>(p => p.Arguments.Render() == "/systray:false")); }
public static IAdvProcess StartIISExpress(this ICakeContext context, ConfigBasedIISExpressSettings settings) { if (context == null) throw new ArgumentNullException("context"); if (settings == null) throw new ArgumentNullException("settings"); var runner = new ConfigBasedIISExpressRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber, context.Registry, context.Log, new AdvProcessRunner(context.Environment, context.Log)); return runner.StartServer(settings); }
public void ShouldThrowWhenIISExpressProcessWritesToErrorStream( [Frozen] IAdvProcess process, [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry, ConfigBasedIISExpressRunner sut) { processRunner.Start(Arg.Any <FilePath>(), Arg.Any <AdvProcessSettings>()).Returns(process); var settings = new ConfigBasedIISExpressSettings(); 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'"); }
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); }
public void ShouldWaitUntilIISExpressServerIsStarted([Frozen] ICakeLog log, [Frozen] IAdvProcess process, [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry, ConfigBasedIISExpressRunner 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 ConfigBasedIISExpressSettings { WaitForStartup = 1000 }; sut.StartServer(settings); log.Received() .Write(Verbosity.Normal, LogLevel.Information, Arg.Is <string>(s => s.StartsWith("IIS Express is running")), Arg.Any <object[]>()); }
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); }
public void ShouldImplementTool(ConfigBasedIISExpressRunner sut) { sut.Should().BeAssignableTo<Tool<ConfigBasedIISExpressSettings>>(); }
public void ShouldSetTraceSwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { TraceLevel = TraceLevel.Warning }; sut.StartServer(settings); runner.Received() .Start(Arg.Any<FilePath>(), Arg.Is<AdvProcessSettings>(p => p.Arguments.Render() == "/trace:warning")); }
public void ShouldThrowWhenIISExpressProcessWritesToErrorStream( [Frozen] IAdvProcess process, [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry, ConfigBasedIISExpressRunner sut) { processRunner.Start(Arg.Any<FilePath>(), Arg.Any<AdvProcessSettings>()).Returns(process); var settings = new ConfigBasedIISExpressSettings(); 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'"); }
public void ShouldWaitUntilIISExpressServerIsStarted([Frozen] ICakeLog log, [Frozen] IAdvProcess process, [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry, ConfigBasedIISExpressRunner 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 ConfigBasedIISExpressSettings { WaitForStartup = 1000 }; sut.StartServer(settings); log.Received() .Write(Verbosity.Normal, LogLevel.Information, Arg.Is<string>(s => s.StartsWith("IIS Express is running")), Arg.Any<object[]>()); }
public void ShouldTimeoutWhenIISExpressTakesLongerThanSpecifiedWaitTimeToStart( [Frozen] ICakeLog log, [Frozen] IAdvProcess process, [Frozen] IAdvProcessRunner processRunner, [Frozen] IRegistry registry, ConfigBasedIISExpressRunner 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 => { Thread.Sleep(100); 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 ConfigBasedIISExpressSettings { WaitForStartup = 50 }; sut.Invoking(s => s.StartServer(settings)) .ShouldThrow<CakeException>() .WithMessage("Timed out while waiting for IIS Express to start. (timeout: 50ms)"); }
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\"")); }
public void ShouldSetSystraySwitch([Frozen] IAdvProcessRunner runner, ConfigBasedIISExpressRunner sut) { var settings = new ConfigBasedIISExpressSettings { EnableSystemTray = false }; sut.StartServer(settings); runner.Received() .Start(Arg.Any<FilePath>(), Arg.Is<AdvProcessSettings>(p => p.Arguments.Render() == "/systray:false")); }
public void ShouldImplementTool(ConfigBasedIISExpressRunner sut) { sut.Should().BeAssignableTo <Tool <ConfigBasedIISExpressSettings> >(); }