public void Setup()
        {
            this.mocks = new MockRepository();

            mockery = new Mockery();
            targetMock = mockery.NewDynamicMock(typeof(IIntegrationRunnerTarget));
            resultManagerMock = mockery.NewDynamicMock(typeof(IIntegrationResultManager));
            quietPeriodMock = mockery.NewDynamicMock(typeof(IQuietPeriod));

            runner = new IntegrationRunner((IIntegrationResultManager)resultManagerMock.MockInstance,
                                           (IIntegrationRunnerTarget)targetMock.MockInstance,
                                           (IQuietPeriod)quietPeriodMock.MockInstance);


            request = ModificationExistRequest();
            endTime = new DateTime(2005, 2, 1);
            modifications = new Modification[] { new Modification() };

            resultMock = mockery.NewDynamicMock(typeof(IIntegrationResult));
            resultMock.SetupResult("WorkingDirectory", TempFileUtil.GetTempPath("workingDir"));
            resultMock.SetupResult("ArtifactDirectory", TempFileUtil.GetTempPath("artifactDir"));
            resultMock.SetupResult("BuildProgressInformation", new ThoughtWorks.CruiseControl.Core.Util.BuildProgressInformation("",string.Empty));
            resultMock.SetupResult("IntegrationProperties", new Dictionary<string, string>());
            result = (IIntegrationResult)resultMock.MockInstance;

            lastResultMock = mockery.NewDynamicMock(typeof(IIntegrationResult));
            lastResult = (IIntegrationResult)lastResultMock.MockInstance;
        }
        public void GenerateSystemParameterValuesShouldUpdateExistingParameters()
        {
            // Initialise the test
            var runner = new IntegrationRunner(null, null, null);
            var result = this.mocks.StrictMock<IIntegrationResult>();
            var integrationProperties = new Dictionary<string, string>
            {
                {
                    "CCNetUser",
                    "John Doe"
                },
                {
                    "CCNetLabel",
                    "1.1"
                }
            };
            SetupResult.For(result.IntegrationProperties).Return(integrationProperties);
            var request = new IntegrationRequest(BuildCondition.ForceBuild, "Test", "John Doe");
            SetupResult.For(result.IntegrationRequest).Return(request);
            var parameters = new List<NameValuePair>();
            SetupResult.For(result.Parameters).Return(parameters);

            // Run the test
            this.mocks.ReplayAll();
            runner.GenerateSystemParameterValues(result);
            integrationProperties["CCNetLabel"] = "1.2";
            runner.GenerateSystemParameterValues(result);

            // Check the results
            this.mocks.VerifyAll();
            Assert.AreEqual(2, request.BuildValues.Count);
            Assert.IsTrue(request.BuildValues.ContainsKey("$CCNetUser"));
            Assert.AreEqual("John Doe", request.BuildValues["$CCNetUser"]);
            Assert.IsTrue(request.BuildValues.ContainsKey("$CCNetLabel"));
            Assert.AreEqual("1.2", request.BuildValues["$CCNetLabel"]);
            Assert.AreEqual(2, parameters.Count);
            Assert.AreEqual("$CCNetUser", parameters[0].Name);
            Assert.AreEqual("John Doe", parameters[0].Value);
            Assert.AreEqual("$CCNetLabel", parameters[1].Name);
            Assert.AreEqual("1.2", parameters[1].Value);
        }