public void StartJob() { // Update HDInsight Management properties for Job. SetupManagementClientForJobTests(); var cmdlet = new StartAzureHDInsightJobCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, HDInsightManagementClient = hdinsightManagementMock.Object, HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()), ClusterName = ClusterName }; var args = new[] { "arg1", "arg2" }; const string query = "show tables;"; const string name = "hivejob"; var hivedef = new AzureHDInsightHiveJobDefinition { JobName = name, Query = query, }; foreach (var arg in args) { hivedef.Arguments.Add(arg); } cmdlet.JobDefinition = hivedef; const string jobid = "jobid_1984120_001"; var jobsub = new JobSubmissionResponse { JobSubmissionJsonResponse = new JobSubmissionJsonResponse { Id = jobid }, StatusCode = HttpStatusCode.OK }; hdinsightJobManagementMock.Setup( c => c.SubmitHiveJob( It.Is <AzureHDInsightHiveJobDefinition>( def => def.JobName == name && def.Query == query && def.Arguments.Count == args.Length))) .Returns(jobsub) .Verifiable(); var getresponse = new JobGetResponse { StatusCode = HttpStatusCode.OK, JobDetail = new JobDetailRootJsonObject { Completed = "false", User = cmdlet.HttpCredential.UserName, Id = jobid, Status = new Status(), Userargs = new Userargs() } }; hdinsightJobManagementMock.Setup(c => c.GetJob(jobsub.JobSubmissionJsonResponse.Id)).Returns(getresponse).Verifiable(); cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is <AzureHDInsightJob>( job => job.Cluster == ClusterName && job.JobId == jobid && job.Completed == "false"))); }
public void StartJob() { // Update HDInsight Management properties for Job. SetupManagementClientForJobTests(); var cmdlet = new StartAzureHDInsightJobCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, HDInsightManagementClient = hdinsightManagementMock.Object, HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()), ClusterName = ClusterName }; var args = new[] {"arg1", "arg2"}; const string query = "show tables;"; const string name = "hivejob"; var hivedef = new AzureHDInsightHiveJobDefinition { JobName = name, Query = query, }; foreach (var arg in args) { hivedef.Arguments.Add(arg); } cmdlet.JobDefinition = hivedef; const string jobid = "jobid_1984120_001"; var jobsub = new JobSubmissionResponse { JobSubmissionJsonResponse = new JobSubmissionJsonResponse { Id = jobid }, StatusCode = HttpStatusCode.OK }; hdinsightJobManagementMock.Setup( c => c.SubmitHiveJob( It.Is<AzureHDInsightHiveJobDefinition>( def => def.JobName == name && def.Query == query && def.Arguments.Count == args.Length))) .Returns(jobsub) .Verifiable(); var getresponse = new JobGetResponse { StatusCode = HttpStatusCode.OK, JobDetail = new JobDetailRootJsonObject { Completed = "false", User = cmdlet.HttpCredential.UserName, Id = jobid, Status = new Status(), Userargs = new Userargs() } }; hdinsightJobManagementMock.Setup(c => c.GetJob(jobsub.JobSubmissionJsonResponse.Id)).Returns(getresponse).Verifiable(); cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is<AzureHDInsightJob>( job => job.Cluster == ClusterName && job.JobId == jobid && job.Completed == "false"))); }