コード例 #1
0
        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);
        }
コード例 #2
0
        public void GenerateSystemParameterValuesShouldAddNewParameters()
        {
            // Initialise the test
            var runner = new IntegrationRunner(null, null, null);
            var result = this.mocks.Create <IIntegrationResult>(MockBehavior.Strict).Object;
            var integrationProperties = new Dictionary <string, string>
            {
                {
                    "CCNetUser",
                    "John Doe"
                },
                {
                    "CCNetLabel",
                    "1.1"
                }
            };

            Mock.Get(result).SetupGet(_result => _result.IntegrationProperties).Returns(integrationProperties);
            var request = new IntegrationRequest(BuildCondition.ForceBuild, "Test", "John Doe");

            Mock.Get(result).SetupGet(_result => _result.IntegrationRequest).Returns(request);
            var parameters = new List <NameValuePair>();

            Mock.Get(result).SetupGet(_result => _result.Parameters).Returns(parameters);

            // Run the test
            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.1", 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.1", parameters[1].Value);
        }