public void ExecuteTestCase(MoveAzureDeploymentTestInputParameters parameters) { var channel = new SimpleServiceManagement { GetDeploymentBySlotThunk = ar => { if (ar.Values["deploymentSlot"].ToString() == DeploymentSlotType.Production) { if (parameters.ProductionDeployment == null) { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), String.Empty); } return parameters.ProductionDeployment; } if (ar.Values["deploymentSlot"].ToString() == DeploymentSlotType.Staging) { if (parameters.StagingDeployment == null) { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), String.Empty); } return parameters.StagingDeployment; } return null; }, SwapDeploymentThunk = ar => { var input = (SwapDeploymentInput)ar.Values["input"]; if (input.Production == null && parameters.ProductionDeployment == null) { if (input.SourceDeployment != parameters.StagingDeployment.Name) { Assert.Fail("Expected values Staging/Prod'{0},{1}', found '{2},{3}'", parameters.StagingDeployment.Name, null, input.SourceDeployment, null); } } else if (input.Production != parameters.ProductionDeployment.Name || input.SourceDeployment != parameters.StagingDeployment.Name) { Assert.Fail("Expected values Staging/Prod'{0},{1}', found '{2},{3}'", parameters.StagingDeployment.Name, parameters.ProductionDeployment.Name, input.SourceDeployment, input.Production); } } }; // Test var moveAzureDeployment = new MoveAzureDeploymentCommand() { ShareChannel = true, Channel = channel, CommandRuntime = new MockCommandRuntime(), ServiceName = "testService", CurrentSubscription = new WindowsAzureSubscription { SubscriptionId = "testId" } }; try { moveAzureDeployment.ExecuteCommand(); if(parameters.ThrowsException) { Assert.Fail(parameters.Description); } } catch (Exception e) { if(e.GetType() != parameters.ExceptionType) { Assert.Fail("Expected exception type is {0}, however found {1}", parameters.ExceptionType, e.GetType()); } if(!parameters.ThrowsException) { Assert.Fail("{0} fails unexpectedly: {1}", parameters.Description, e); } } }