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); }
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); }
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); }
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); }); }