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 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[]>());
        }