protected override void AdditionalSetup() { _settingsModel = new OdsInstanceSettingsModel { LearningStandardsModel = new LearningStandardsModel { ApiKey = ApiKey, ApiSecret = ApiSecret } }; ApiModeProvider .Setup(x => x.GetApiMode()) .Returns(ApiMode.Sandbox); ApiConnectionInformationProvider .Setup(x => x.GetConnectionInformationForEnvironment(CloudOdsEnvironment.Production)) .ReturnsAsync(new OdsApiConnectionInformation("Ods Instance", ApiMode.Sandbox) { ApiServerUrl = ProductionUrl }); LearningStandardsSetupCommand.Setup(x => x.Execute(It.IsAny <AcademicBenchmarkConfig>())) .Returns(Task.CompletedTask); LearningStandardsJob.Setup(x => x.EnqueueJob(It.IsAny <LearningStandardsJobContext>())); }
protected override void AdditionalSetup() { InstanceContext.Id = _instanceContext.Id; InstanceContext.Name = _instanceContext.Name; _learningStandardsModel = new LearningStandardsModel { ApiKey = ApiKey, ApiSecret = ApiSecret }; ApiModeProvider .Setup(x => x.GetApiMode()) .Returns(ApiMode.DistrictSpecific); ApiConnectionInformationProvider .Setup(x => x.GetConnectionInformationForEnvironment()) .ReturnsAsync(new OdsApiConnectionInformation(_instanceContext.Name, ApiMode.DistrictSpecific) { ApiServerUrl = ProductionUrl }); LearningStandardsSetupCommand.Setup(x => x.Execute(It.IsAny <AcademicBenchmarkConfig>())) .Returns(Task.CompletedTask); LearningStandardsJob.Setup(x => x.EnqueueJob(It.IsAny <LearningStandardsJobContext>())); }
protected override void AdditionalSetup() { ApiModeProvider .Setup(x => x.GetApiMode()) .Returns(ApiMode.Sandbox); ApiConnectionInformationProvider .Setup(x => x.GetConnectionInformationForEnvironment()) .ReturnsAsync(new OdsApiConnectionInformation("Ods Instance", ApiMode.Sandbox) { ApiServerUrl = ProductionUrl }); LearningStandardsJob.Setup(x => x.EnqueueJob(It.IsAny <LearningStandardsJobContext>())); }
protected override void AdditionalSetup() { InstanceContext.Id = _instanceContext.Id; InstanceContext.Name = _instanceContext.Name; ApiModeProvider .Setup(x => x.GetApiMode()) .Returns(ApiMode.YearSpecific); ApiConnectionInformationProvider .Setup(x => x.GetConnectionInformationForEnvironment()) .ReturnsAsync(new OdsApiConnectionInformation(_instanceContext.Name, ApiMode.YearSpecific) { ApiServerUrl = ProductionUrl }); LearningStandardsJob.Setup(x => x.EnqueueJob(It.IsAny <LearningStandardsJobContext>())); }
private OdsInstanceSettingsModel SetupBulkUpload(out FileUploadResult fileUploadResult) { const string filename = "test.xml"; var file = new Mock <HttpPostedFileBase>(); file.Setup(x => x.ContentLength).Returns(200); file.Setup(x => x.FileName).Returns("test.xml"); var model = new OdsInstanceSettingsModel { BulkFileUploadModel = new BulkFileUploadModel { BulkFiles = new List <HttpPostedFileBase> { file.Object } } }; fileUploadResult = new FileUploadResult { Directory = "directoryPath", FileNames = new[] { filename } }; InstanceContext.Id = OdsInstanceContext.Id; InstanceContext.Name = OdsInstanceContext.Name; FileUploadHandler.Setup(x => x.SaveFilesToUploadDirectory(It.IsAny <HttpPostedFileBase[]>(), It.IsAny <Func <string, string> >())) .Returns(fileUploadResult); ApiConnectionInformationProvider .Setup(x => x.GetConnectionInformationForEnvironment(CloudOdsEnvironment.Production)) .ReturnsAsync(_connectionInformation); OdsSecretConfigurationProvider.Setup(x => x.GetSecretConfiguration(It.IsAny <int>())) .Returns(Task.FromResult(OdsSecretConfig)); return(model); }
private BulkFileUploadModel SetupBulkUpload(out FileUploadResult fileUploadResult) { const string filename = "test.xml"; var file = new Mock <IFormFile>(); file.Setup(x => x.Length).Returns(200); file.Setup(x => x.FileName).Returns("test.xml"); var model = new BulkFileUploadModel { BulkFileType = InterchangeFileType.AssessmentMetadata.Value, BulkFiles = new List <IFormFile> { file.Object } }; fileUploadResult = new FileUploadResult { Directory = "directoryPath", FileNames = new[] { filename } }; InstanceContext.Id = OdsInstanceContext.Id; InstanceContext.Name = OdsInstanceContext.Name; FileUploadHandler.Setup(x => x.SaveFilesToUploadDirectory(It.IsAny <IFormFile[]>(), It.IsAny <Func <string, string> >(), WebHostingEnvironment.Object)) .Returns(fileUploadResult); ApiConnectionInformationProvider .Setup(x => x.GetConnectionInformationForEnvironment()) .ReturnsAsync(_connectionInformation); OdsSecretConfigurationProvider.Setup(x => x.GetSecretConfiguration(It.IsAny <int>())) .Returns(Task.FromResult(OdsSecretConfig)); return(model); }
public async Task ThenModelIsInitializedWithOdsInstanceSettings() { // Arrange var productionTab = new List <TabDisplay <OdsInstanceSettingsTabEnumeration> >(); TabDisplayService.Setup(x => x.GetOdsInstanceSettingsTabDisplay(OdsInstanceSettingsTabEnumeration.Applications)) .Returns(productionTab); const string baseUrl = "http://example.com"; ApiConnectionInformationProvider.Setup(x => x.GetConnectionInformationForEnvironment(CloudOdsEnvironment.Production)) .ReturnsAsync(new OdsApiConnectionInformation("Ods Instance", ApiMode.Sandbox) { ApiServerUrl = baseUrl }); // Act var result = await SystemUnderTest.Applications(); // Assert result.ShouldNotBeNull(); result.ShouldBeOfType <ViewResult>(); var viewResult = result as ViewResult; // ReSharper disable PossibleNullReferenceException - assertions are the guard clauses viewResult.Model.ShouldBeOfType <OdsInstanceSettingsModel>(); var model = viewResult.Model as OdsInstanceSettingsModel; model.ShouldSatisfyAllConditions( () => model.OdsInstanceSettingsTabEnumerations.ShouldBeSameAs(productionTab), () => model.ProductionApiUrl.ShouldContain(baseUrl) ); // ReSharper restore PossibleNullReferenceException }