public async Task When_Perform_Post_Request_To_BulkFileUpload_Against_ODS3_Job_Should_Be_Enqueued_With_Pessimistic_Throttling() { const string odsApiVersion = "3.4.0"; const string edfiStandardVersion = "3.2.0-b"; InferOdsApiVersion.Setup(x => x.Version("http://example.com")).Returns(odsApiVersion); InferOdsApiVersion.Setup(x => x.EdFiStandardVersion("http://example.com")).Returns(edfiStandardVersion); var model = SetupBulkUpload(out var fileUploadResult); BulkUploadJob.Setup(x => x.IsJobRunning()).Returns(false); BulkUploadJob.Setup(x => x.IsSameOdsInstance(OdsInstanceContext.Id, typeof(BulkUploadJobContext))).Returns(true); var result = (PartialViewResult)await SystemUnderTest.BulkFileUpload(model); // Assert Func <BulkUploadJobContext, bool> bulkUploadJobEnqueueVerifier = actual => { actual.MaxSimultaneousRequests.ShouldBe(1); return(true); }; result.ShouldNotBeNull(); result.ViewName.ShouldBe("_SignalRStatus_BulkLoad"); result.Model.ShouldNotBeNull(); var settingsModel = (OdsInstanceSettingsModel)result.Model; settingsModel.BulkFileUploadModel.ShouldNotBeNull(); settingsModel.BulkFileUploadModel.IsSameOdsInstance.ShouldBeTrue(); BulkUploadJob.Verify( x => x.EnqueueJob(It.Is <BulkUploadJobContext>(y => bulkUploadJobEnqueueVerifier(y))), Times.Once); }
public async Task When_Job_Is_Already_Running_New_Job_Should_Not_Be_Enqueued() { const string odsApiVersion = "3.4.0"; const string edfiStandardVersion = "3.2.0-b"; InferOdsApiVersion.Setup(x => x.Version("http://example.com")).Returns(odsApiVersion); InferOdsApiVersion.Setup(x => x.EdFiStandardVersion("http://example.com")).Returns(edfiStandardVersion); var model = SetupBulkUpload(out var fileUploadResult); BulkUploadJob.Setup(x => x.IsJobRunning()).Returns(true); BulkUploadJob.Setup(x => x.IsSameOdsInstance(OdsInstanceContext.Id, typeof(BulkUploadJobContext))).Returns(true); var result = (PartialViewResult)await SystemUnderTest.BulkFileUpload(model); // Assert result.ShouldNotBeNull(); result.ViewName.ShouldBe("_SignalRStatus_BulkLoad"); result.Model.ShouldNotBeNull(); var settingsModel = (OdsInstanceSettingsModel)result.Model; settingsModel.BulkFileUploadModel.ShouldNotBeNull(); settingsModel.BulkFileUploadModel.IsJobRunning.ShouldBeTrue(); settingsModel.BulkFileUploadModel.IsSameOdsInstance.ShouldBeTrue(); BulkUploadJob.Verify( x => x.EnqueueJob(It.IsAny <BulkUploadJobContext>()), Times.Never); }
public async Task When_Perform_Post_Request_To_BulkFileUpload_With_Valid_File_Job_Should_Be_Enqueued() { const string odsApiVersion = "5.0.0"; const string edfiStandardVersion = "3.2.0-c"; InferOdsApiVersion.Setup(x => x.Version("http://example.com")).Returns(odsApiVersion); InferOdsApiVersion.Setup(x => x.EdFiStandardVersion("http://example.com")).Returns(edfiStandardVersion); var schemaBasePath = HostingEnvironment.MapPath(ConfigurationManager.AppSettings["XsdFolder"]); var schemaPath = $"{schemaBasePath}\\{edfiStandardVersion}"; var model = SetupBulkUpload(out var fileUploadResult); BulkUploadJob.Setup(x => x.IsJobRunning()).Returns(false); BulkUploadJob.Setup(x => x.IsSameOdsInstance(OdsInstanceContext.Id, typeof(BulkUploadJobContext))).Returns(true); var result = (PartialViewResult)await SystemUnderTest.BulkFileUpload(model); // Assert Func <BulkUploadJobContext, bool> bulkUploadJobEnqueueVerifier = actual => { actual.ShouldSatisfyAllConditions( () => actual.Environment.ShouldBe(CloudOdsEnvironment.Production.Value), () => actual.DataDirectoryFullPath.ShouldBe(fileUploadResult.Directory), () => actual.OdsInstanceId.ShouldBe(OdsInstanceContext.Id), () => actual.ApiBaseUrl.ShouldBe(_connectionInformation.ApiBaseUrl), () => actual.ClientKey.ShouldBe(_connectionInformation.ClientKey), () => actual.ClientSecret.ShouldBe(_connectionInformation.ClientSecret), () => actual.DependenciesUrl.ShouldBe(_connectionInformation.DependenciesUrl), () => actual.MetadataUrl.ShouldBe(_connectionInformation.MetadataUrl), () => actual.OauthUrl.ShouldBe(_connectionInformation.OAuthUrl), () => actual.SchemaPath.ShouldBe(schemaPath), () => actual.MaxSimultaneousRequests.ShouldBe(20) ); return(true); }; result.ShouldNotBeNull(); result.ViewName.ShouldBe("_SignalRStatus_BulkLoad"); result.Model.ShouldNotBeNull(); var settingsModel = (OdsInstanceSettingsModel)result.Model; settingsModel.BulkFileUploadModel.ShouldNotBeNull(); settingsModel.BulkFileUploadModel.IsSameOdsInstance.ShouldBeTrue(); BulkUploadJob.Verify( x => x.EnqueueJob(It.Is <BulkUploadJobContext>(y => bulkUploadJobEnqueueVerifier(y))), Times.Once); }