Ejemplo n.º 1
0
        public void GenericHandlerDeployerTest(string url, string expected)
        {
            // Arrange
            var handler = new GenericHandler();
            var payload = new JObject();
            payload["url"] = url;
            payload["format"] = "basic";

            // Act
            DeploymentInfo deploymentInfo;
            DeployAction result = handler.TryParseDeploymentInfo(request: null, payload: payload, targetBranch: null, deploymentInfo: out deploymentInfo);

            // Assert
            Assert.Equal(DeployAction.ProcessDeployment, result);
            Assert.NotNull(deploymentInfo);
            Assert.Equal(expected, deploymentInfo.Deployer);
        }
Ejemplo n.º 2
0
        public void GenericHandlerSimpleTest(DeployAction expected, IDictionary<string, object> values)
        {
            // Arrange
            var handler = new GenericHandler();
            var payload = new JObject();
            foreach (var pair in values)
            {
                payload[pair.Key] = JToken.FromObject(pair.Value);
            }

            // Act
            DeploymentInfo deploymentInfo;
            DeployAction result = handler.TryParseDeploymentInfo(request: null, payload: payload, targetBranch: null, deploymentInfo: out deploymentInfo);

            // Assert
            Assert.Equal(expected, result);
        }
Ejemplo n.º 3
0
        public void GenericHandlerRepositoryTypeTest(string url, bool? is_hg, RepositoryType expected)
        {
            // Arrange
            var handler = new GenericHandler();
            var payload = new JObject();
            payload["url"] = url;
            payload["format"] = "basic";
            if (is_hg != null)
            {
                payload["scm"] = is_hg.Value ? "hg" : "git";
            }

            // Act
            DeploymentInfo deploymentInfo;
            DeployAction result = handler.TryParseDeploymentInfo(request: null, payload: payload, targetBranch: null, deploymentInfo: out deploymentInfo);

            // Assert
            Assert.Equal(DeployAction.ProcessDeployment, result);
            Assert.NotNull(deploymentInfo);
            Assert.Equal(expected, deploymentInfo.RepositoryType);
        }
Ejemplo n.º 4
0
        public void GenericHandlerInvalidUrl(string url)
        {
            // Arrange
            var handler = new GenericHandler();
            var payload = new JObject();
            payload["url"] = url;
            payload["format"] = "basic";

            // Act
            DeploymentInfo deploymentInfo;

            // Assert
            Assert.Throws<InvalidOperationException>(() =>
            {
                handler.TryParseDeploymentInfo(request: null, payload: payload, targetBranch: null, deploymentInfo: out deploymentInfo);
            });
        }