public void CloudJob_WhenSendingToTheServer_HasExpectedUnboundProperties() { const string jobId = "id-123"; const string displayName = "DisplayNameFoo"; MetadataItem metadataItem = new MetadataItem("foo", "bar"); const int priority = 0; const string applicationId = "testApp"; const string applicationVersion = "beta"; using BatchClient client = ClientUnitTestCommon.CreateDummyClient(); CloudJob cloudJob = client.JobOperations.CreateJob(jobId, new PoolInformation { AutoPoolSpecification = new AutoPoolSpecification { KeepAlive = false } }); cloudJob.Id = jobId; cloudJob.DisplayName = displayName; cloudJob.Metadata = new List <MetadataItem> { metadataItem }; cloudJob.Priority = priority; cloudJob.JobManagerTask = new JobManagerTask { ApplicationPackageReferences = new List <ApplicationPackageReference> { new ApplicationPackageReference { ApplicationId = applicationId, Version = applicationVersion } }, AuthenticationTokenSettings = new AuthenticationTokenSettings() { Access = AccessScope.Job } }; cloudJob.OnAllTasksComplete = OnAllTasksComplete.NoAction; cloudJob.OnTaskFailure = OnTaskFailure.NoAction; Assert.Throws <InvalidOperationException>(() => cloudJob.Url); // cannot read a Url since it's unbound at this point. Assert.Equal(cloudJob.Id, jobId); // can set an unbound object Assert.Equal(cloudJob.Metadata.First().Name, metadataItem.Name); Assert.Equal(cloudJob.Metadata.First().Value, metadataItem.Value); Assert.Equal(OnAllTasksComplete.NoAction, cloudJob.OnAllTasksComplete); Assert.Equal(OnTaskFailure.NoAction, cloudJob.OnTaskFailure); cloudJob.Commit(additionalBehaviors: InterceptorFactory.CreateAddJobRequestInterceptor()); // writing isn't allowed for a job that is in an invalid state. Assert.Throws <InvalidOperationException>(() => cloudJob.Id = "cannot-change-id"); Assert.Throws <InvalidOperationException>(() => cloudJob.DisplayName = "cannot-change-display-name"); AuthenticationTokenSettings authenticationTokenSettings = new AuthenticationTokenSettings { Access = AccessScope.Job }; Assert.Throws <InvalidOperationException>(() => { cloudJob.JobManagerTask.AuthenticationTokenSettings = authenticationTokenSettings; }); }
private int GetMaxUsageCount(AuthenticationTokenSettings settings) { if (settings != null) { return(settings.maxUsageCount); } else { return(1); } }