public void ShouldBeAbleToSaveProjectsThatALoaderCanLoad()
		{
			ExecutableTask builder = new ExecutableTask();
			builder.Executable = "foo";
			FileSourceControl sourceControl = new FileSourceControl();
			sourceControl.RepositoryRoot = "bar";
			// Setup
			Project project1 = new Project();
			project1.Name = "Project One";
			project1.SourceControl = sourceControl;
			Project project2 = new Project();
			project2.Name = "Project Two";
			project2.SourceControl = sourceControl;
			ProjectList projectList = new ProjectList();
			projectList.Add(project1);
			projectList.Add(project2);

			DynamicMock mockConfiguration = new DynamicMock(typeof(IConfiguration));
			mockConfiguration.ExpectAndReturn("Projects", projectList);

			FileInfo configFile = new FileInfo(TempFileUtil.CreateTempFile(TempFileUtil.CreateTempDir(this), "loadernet.config"));

			// Execute
			DefaultConfigurationFileSaver saver = new DefaultConfigurationFileSaver(new NetReflectorProjectSerializer());
			saver.Save((IConfiguration) mockConfiguration.MockInstance, configFile);

			DefaultConfigurationFileLoader loader = new DefaultConfigurationFileLoader();
			IConfiguration configuration2 = loader.Load(configFile);

			// Verify
			Assert.IsNotNull (configuration2.Projects["Project One"]);
			Assert.IsNotNull (configuration2.Projects["Project Two"]);
			mockConfiguration.Verify();
		}
		public void CreatesProjectIntegrators()
		{
			// Setup
			Project project1 = new Project();
			project1.Name = "Project 1";
			Project project2 = new Project();
			project2.Name = "Project 2";
			ProjectList projectList = new ProjectList();
			projectList.Add(project1);
			projectList.Add(project2);

			// Execute
			IntegrationQueueSet integrationQueues = new IntegrationQueueSet();
			IProjectIntegratorList integrators = new ProjectIntegratorListFactory().CreateProjectIntegrators(projectList, integrationQueues);

			// Verify
			Assert.AreEqual(2, integrators.Count);
			Assert.AreEqual(project1, integrators["Project 1"].Project );
			Assert.AreEqual(project2, integrators["Project 2"].Project );
		}
        /// <summary>
        /// Initialises the server.
        /// </summary>
        /// <param name="mocks">The mocks repository.</param>
        /// <param name="buildName">Name of the build.</param>
        /// <param name="buildLog">The build log.</param>
        /// <returns>The initialised server.</returns>
        private static CruiseServer InitialiseServer(MockRepository mocks, string buildName, string buildLog)
        {
            // Add some projects
            var projects = new ProjectList();
            var project = new Project
            {
                Name = testProjectName
            };
            projects.Add(project);

            // Mock the configuration
            var configuration = mocks.StrictMock<IConfiguration>();
            SetupResult.For(configuration.Projects)
                .Return(projects);
            SetupResult.For(configuration.SecurityManager)
                .Return(new NullSecurityManager());

            // Mock the configuration service
            var configService = mocks.StrictMock<IConfigurationService>();
            SetupResult.For(configService.Load())
                .Return(configuration);
            Expect.Call(() => { configService.AddConfigurationUpdateHandler(null); })
                .IgnoreArguments();

            // Mock the integration repostory
            var repository = mocks.StrictMock<IIntegrationRepository>();
            SetupResult.For(repository.GetBuildLog(buildName))
                .Return(buildLog);

            // Mock the project integrator
            var projectIntegrator = mocks.StrictMock<IProjectIntegrator>();
            SetupResult.For(projectIntegrator.Project)
                .Return(project);
            SetupResult.For(projectIntegrator.IntegrationRepository)
                .Return(repository);

            // Mock the queue manager
            var queueManager = mocks.StrictMock<IQueueManager>();
            Expect.Call(() => { queueManager.AssociateIntegrationEvents(null, null); })
                .IgnoreArguments();
            SetupResult.For(queueManager.GetIntegrator(testProjectName))
                .Return(projectIntegrator);

            // Mock the queue manager factory
            var queueManagerFactory = mocks.StrictMock<IQueueManagerFactory>();
            SetupResult.For(queueManagerFactory.Create(null, configuration, null))
                .Return(queueManager);
            IntegrationQueueManagerFactory.OverrideFactory(queueManagerFactory);

            // Mock the execution environment
            var execEnviron = mocks.StrictMock<IExecutionEnvironment>();
            SetupResult.For(execEnviron.GetDefaultProgramDataFolder(ApplicationType.Server))
                .Return(string.Empty);

            // Initialise the server
            mocks.ReplayAll();
            var server = new CruiseServer(
                configService,
                null,
                null,
                null,
                null,
                execEnviron,
                null);
            return server;
        }