public RevisionControlStatsModule(
     IRevisionControlHistoryFacility rcHistoryFacility,
     IProjectRegistry projectRegistry,
     IFileManager fileManager,
     ITemplateEngine templateEngine)
 {
     this.rcHistoryFacility = rcHistoryFacility;
     this.projectRegistry   = projectRegistry;
     this.fileManager       = fileManager;
     this.templateEngine    = templateEngine;
 }
        public void Test()
        {
            ProjectPilotConfiguration projectPilotConfiguration = new ProjectPilotConfiguration();

            projectPilotConfiguration.ProjectPilotWebAppRootUrl = "http://localhost/projectpilot/";

            ProjectRegistry projectRegistry = new ProjectRegistry();
            Project         project         = new Project("bhwr", "Mobilkom BHWR");

            projectRegistry.AddProject(project);

            IFileManager fileManager = new DefaultFileManager(string.Empty, projectPilotConfiguration);

            projectRegistry.FileManager = fileManager;

            IFileManager templateFileManager = MockRepository.GenerateStub <IFileManager>();

            templateFileManager.Stub(action => action.GetFullFileName(null, null)).IgnoreArguments().Return(@"..\..\..\Data\Templates\RevisionControlHistory.vm");

            ITemplateEngine templateEngine = new DefaultTemplateEngine(templateFileManager);

            // prepare test history data
            RevisionControlHistoryData data;

            using (Stream stream = File.OpenRead(@"..\..\..\Data\Samples\svn-log.xml"))
            {
                data = SubversionHistoryFacility.LoadHistory(stream);
            }

            IRevisionControlHistoryFacility revisionControlHistoryFacility = MockRepository.GenerateStub <IRevisionControlHistoryFacility>();

            revisionControlHistoryFacility.Stub(action => action.FetchHistory()).Return(data);

            //IRevisionControlHistoryFacility revisionControlHistoryFacility = new SubversionHistoryFacility(
            //    project.CorrelationId,
            //    @"C:\Program Files\CollabNet Subversion\svn.exe",
            //    @"D:\svn\mobilkom.nl-bhwr\trunk\src");

            RevisionControlStatsModule module = new RevisionControlStatsModule(
                revisionControlHistoryFacility,
                projectRegistry,
                fileManager,
                templateEngine);

            module.ProjectId = "bhwr";
            project.AddModule(module);

            module.ExecuteTask(null);
        }
        public void StartAndStopRunner()
        {
            WindsorContainer windsorContainer = new WindsorContainer(@"SampleConfigurations\ProjectPilot.config.xml");

            windsorContainer.Kernel.ComponentCreated      += new Castle.MicroKernel.ComponentInstanceDelegate(Kernel_ComponentCreated);
            windsorContainer.Kernel.ComponentModelCreated += new Castle.MicroKernel.ComponentModelDelegate(Kernel_ComponentModelCreated);
            windsorContainer.Kernel.ComponentRegistered   += new Castle.MicroKernel.ComponentDataDelegate(Kernel_ComponentRegistered);
            windsorContainer.Kernel.DependencyResolving   += new Castle.MicroKernel.DependencyDelegate(Kernel_DependencyResolving);
            windsorContainer.Kernel.HandlerRegistered     += new Castle.MicroKernel.HandlerDelegate(Kernel_HandlerRegistered);

            WindsorContainerGraphs.GenerateDependencyGraph(windsorContainer, "graph.dot");

            IStatePersistence mockStatePersistence = MockRepository.GenerateMock <IStatePersistence>();

            // prepare test history data
            RevisionControlHistoryData data;

            using (Stream stream = File.OpenRead(@"..\..\..\Data\Samples\svn-log.xml"))
            {
                data = SubversionHistoryFacility.LoadHistory(stream);
            }

            IRevisionControlHistoryFacility mockRcsHistoryFacility = MockRepository.GenerateMock <IRevisionControlHistoryFacility>();

            mockRcsHistoryFacility.Stub(action => action.FetchHistory()).Return(data);

            windsorContainer.Kernel.AddComponentInstance("RcsHistoryFacility", typeof(IRevisionControlHistoryFacility), mockRcsHistoryFacility);

            using (IRunner runner = windsorContainer.Resolve <IRunner>())
            {
                Project[] projects = windsorContainer.Kernel.ResolveServices <Project>();

                IProjectRegistry projectRegistry = windsorContainer.Resolve <IProjectRegistry>();
                Assert.AreEqual(1, projectRegistry.ProjectsCount);

                Project project = projectRegistry.GetProject("projectpilot");
                Assert.IsNotNull(project);

                Assert.AreEqual(1, project.ModulesCount);
                IProjectModule module = project.GetModule("RevisionControlStats");

                runner.Start();
                Thread.Sleep(5000);
            }
        }