Ejemplo n.º 1
0
        public void Test()
        {
            HeadlessMother mother = new HeadlessMother();

            IService mockService = MockRepository.GenerateStub <IService>();

            ServiceInfo serviceInfo = new ServiceInfo();

            serviceInfo.ComputerName = "computer";
            serviceInfo.PortNumber   = 3434;

            mockService.Expect(s => s.GetServiceInfo()).Return(serviceInfo).Repeat.Any();

            IWebRouteProcessor mainPageProcessor     = new MainPageProcessor(mockService, mother.ProjectRegistry);
            IWebRouteProcessor fileWebRouteProcessor = new FileWebRouteProcessor();

            DefaultWebRequestRouter webRequestRouter = new DefaultWebRequestRouter();

            webRequestRouter.AddRoute(@".*\.css$", fileWebRouteProcessor);
            webRequestRouter.AddRoute(@".*", mainPageProcessor);

            IWebRequestProcessor webRequestProcessor = new DefaultWebRequestProcessor(webRequestRouter);

            //string response = webRequestProcessor.ProcessRequest(new Uri("http://localhost:23232/"));

            using (WebServer webServer = new WebServer(serviceInfo, webRequestProcessor))
            {
                webServer.Start();
                Thread.Sleep(TimeSpan.FromSeconds(20));
                webServer.Stop();
            }
        }
Ejemplo n.º 2
0
        public void CheckTriggersQueue()
        {
            HeadlessMother mother        = new HeadlessMother();
            IThreadFactory threadFactory = new DefaultThreadFactory();
            IWorkerMonitor workerMonitor = mother.WorkerMonitor;

            using (ManualResetEvent stopSignal = new ManualResetEvent(false))
            {
                JobQueue <ProjectRelatedJob> buildQueue = new JobQueue <ProjectRelatedJob>("buildQueue", stopSignal);

                using (CheckTriggersQueueFeeder checkTriggersQueueFeeder = new CheckTriggersQueueFeeder(
                           stopSignal,
                           buildQueue,
                           threadFactory,
                           workerMonitor,
                           mother.ProjectRegistry))
                {
                    checkTriggersQueueFeeder.Start();
                    Thread.Sleep(TimeSpan.FromSeconds(10));
                    stopSignal.Set();

                    threadFactory.WaitForAllThreadsToStop(TimeSpan.FromSeconds(5));
                }
            }

            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("ProjectPilot", ProjectStatus.CheckingTriggers));
            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("Headless", ProjectStatus.CheckingTriggers));
            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("Flubu", ProjectStatus.CheckingTriggers));
            mother.ProjectRegistry.VerifyAllExpectations();
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            mother = new HeadlessMother();

            mockBuildTrafficSignals     = MockRepository.GenerateMock <IBuildTrafficSignals>();
            mockBuildStageRunnerFactory = MockRepository.GenerateMock <IBuildStageRunnerFactory>();
            logger = new DefaultHeadlessLogger();

            project = new Project("Headless");

            buildStage1           = new BuildStage("stage1", this.project);
            buildStage2           = new BuildStage("stage2", this.project);
            buildStageAcceptTests = new BuildStage("accept.tests", this.project);

            buildStageAcceptTests.BuildComputer = "other";

            buildStage2.DependsOn.Add(this.buildStage1);
            buildStageAcceptTests.DependsOn.Add(this.buildStage1);

            project.BuildStages.Add(this.buildStage1);
            project.BuildStages.Add(this.buildStage2);
            project.BuildStages.Add(this.buildStageAcceptTests);

            IStageRunner stageRunner1 = new LocalStageRunner(this.logger);

            stageRunner1.SetBuildStage(this.buildStage1);
            IStageRunner stageRunner2 = new LocalStageRunner(this.logger);

            stageRunner2.SetBuildStage(this.buildStage2);
            IStageRunner stageRunner3 = new LocalStageRunner(this.logger);

            stageRunner3.SetBuildStage(this.buildStageAcceptTests);

            this.mockBuildStageRunnerFactory.Expect(factory => factory.CreateStageRunner(this.buildStage1)).Return(stageRunner1).Repeat.Once();
            this.mockBuildStageRunnerFactory.Expect(factory => factory.CreateStageRunner(this.buildStage2)).Return(stageRunner2).Repeat.Once();
            this.mockBuildStageRunnerFactory.Expect(factory => factory.CreateStageRunner(this.buildStageAcceptTests)).Return(stageRunner3).Repeat.Once();

            mockBuildTaskSuccess = MockRepository.GenerateMock <IBuildTask>();
            this.mockBuildTaskSuccess.Expect(task => task.Execute()).WhenCalled(delegate { Thread.Sleep(3000); });

            mockBuildTaskFailure = MockRepository.GenerateMock <IBuildTask>();
            this.mockBuildTaskFailure.Expect(task => task.Execute()).WhenCalled(delegate
            {
                Thread.Sleep(3000);
                throw new InvalidOperationException();
            });

            this.mockBuildTrafficSignals.Expect(cop => cop.WaitForControlSignal(TimeSpan.Zero))
            .IgnoreArguments().WhenCalled(delegate { Thread.Sleep(5000); }).Return(BuildTrafficCopSignal.NoSignal)
            .Repeat.Any();
        }
Ejemplo n.º 4
0
        public void HeadlessServiceTest()
        {
            HeadlessMother mother        = new HeadlessMother();
            IThreadFactory threadFactory = new DefaultThreadFactory();

            mother.ProjectRegistry.Expect(r => r.ChangeProjectStatus("Headless", ProjectStatus.CheckingTriggers)).Repeat
            .Any();

            using (HeadlessService service = new HeadlessService(
                       mother.ProjectRegistry,
                       threadFactory,
                       mother.WorkerMonitor,
                       mother.HeadlessLogger))
            {
                service.Start();
                Thread.Sleep(TimeSpan.FromSeconds(20));
                service.Stop(TimeSpan.FromSeconds(5));
            }

            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("Headless", ProjectStatus.Sleeping));
            mother.ProjectRegistry.AssertWasNotCalled(r => r.ChangeProjectStatus("ProjectPilot", ProjectStatus.Building));
            mother.ProjectRegistry.AssertWasNotCalled(r => r.ChangeProjectStatus("Flubu", ProjectStatus.Building));
            mother.ProjectRegistry.VerifyAllExpectations();
        }