public async Task UnboundJobScheduleCommitAndRefreshWorks() { using (BatchClient batchClient = ClientUnitTestCommon.CreateDummyClient()) { const string id = "Bar"; const string displayName = "Baz"; var jobSpecification = new Protocol.Models.JobSpecification() { DisplayName = displayName }; var protoJobSchedule = new Protocol.Models.CloudJobSchedule( id: id, displayName: displayName, jobSpecification: jobSpecification); CloudJobSchedule jobSchedule = batchClient.JobScheduleOperations.CreateJobSchedule(id, new Schedule(), null); await jobSchedule.CommitAsync(additionalBehaviors : InterceptorFactory.CreateAddJobScheduleRequestInterceptor()); await jobSchedule.RefreshAsync(additionalBehaviors : InterceptorFactory.CreateGetJobScheduleRequestInterceptor(protoJobSchedule)); Assert.Equal(id, jobSchedule.Id); Assert.Equal(displayName, jobSchedule.DisplayName); Assert.Null(jobSchedule.Schedule); Assert.NotNull(jobSchedule.JobSpecification); Assert.Equal(jobSpecification.DisplayName, jobSchedule.JobSpecification.DisplayName); } }
public void CloudJobSchedule_WhenSendingToTheServer_HasExpectedUnboundProperties() { const string jobScheduleId = "id-123"; const string displayName = "DisplayNameFoo"; MetadataItem metadataItem = new MetadataItem("foo", "bar"); BatchSharedKeyCredentials credentials = ClientUnitTestCommon.CreateDummySharedKeyCredential(); using (BatchClient client = BatchClient.Open(credentials)) { CloudJobSchedule jobSchedule = client.JobScheduleOperations.CreateJobSchedule(); jobSchedule.Id = jobScheduleId; jobSchedule.DisplayName = displayName; jobSchedule.Metadata = new List <MetadataItem> { metadataItem }; Assert.Equal(jobSchedule.Id, jobScheduleId); // can set an unbound object Assert.Equal(jobSchedule.Metadata.First().Name, metadataItem.Name); Assert.Equal(jobSchedule.Metadata.First().Value, metadataItem.Value); jobSchedule.Commit(additionalBehaviors: InterceptorFactory.CreateAddJobScheduleRequestInterceptor()); // writing isn't allowed for a jobSchedule that is in an read only state. Assert.Throws <InvalidOperationException>(() => jobSchedule.Id = "cannot-change-id"); Assert.Throws <InvalidOperationException>(() => jobSchedule.DisplayName = "cannot-change-display-name"); //Can still read though Assert.Equal(jobScheduleId, jobSchedule.Id); Assert.Equal(displayName, jobSchedule.DisplayName); } }
public void CloudJobSchedule_WhenSendingToTheServer_HasExpectedUnboundProperties() { const string jobScheduleId = "id-123"; const string displayName = "DisplayNameFoo"; MetadataItem metadataItem = new MetadataItem("foo", "bar"); using (BatchClient client = ClientUnitTestCommon.CreateDummyClient()) { CloudJobSchedule jobSchedule = client.JobScheduleOperations.CreateJobSchedule(); jobSchedule.Id = jobScheduleId; jobSchedule.DisplayName = displayName; jobSchedule.Metadata = new List <MetadataItem> { metadataItem }; jobSchedule.JobSpecification = new JobSpecification { OnAllTasksComplete = OnAllTasksComplete.TerminateJob, OnTaskFailure = OnTaskFailure.PerformExitOptionsJobAction }; Assert.Equal(jobSchedule.Id, jobScheduleId); // can set an unbound object Assert.Equal(jobSchedule.Metadata.First().Name, metadataItem.Name); Assert.Equal(jobSchedule.Metadata.First().Value, metadataItem.Value); Assert.Equal(OnAllTasksComplete.TerminateJob, jobSchedule.JobSpecification.OnAllTasksComplete); Assert.Equal(OnTaskFailure.PerformExitOptionsJobAction, jobSchedule.JobSpecification.OnTaskFailure); jobSchedule.Commit(additionalBehaviors: InterceptorFactory.CreateAddJobScheduleRequestInterceptor()); // writing isn't allowed for a jobSchedule that is in an read only state. Assert.Throws <InvalidOperationException>(() => jobSchedule.Id = "cannot-change-id"); Assert.Throws <InvalidOperationException>(() => jobSchedule.DisplayName = "cannot-change-display-name"); //Can still read though Assert.Equal(jobScheduleId, jobSchedule.Id); Assert.Equal(displayName, jobSchedule.DisplayName); jobSchedule.Refresh(additionalBehaviors: InterceptorFactory.CreateGetJobScheduleRequestInterceptor( new Models.CloudJobSchedule() { JobSpecification = new Models.JobSpecification() })); jobSchedule.JobSpecification.OnAllTasksComplete = OnAllTasksComplete.NoAction; jobSchedule.JobSpecification.OnTaskFailure = OnTaskFailure.NoAction; } }