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);
        }
示例#2
0
        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);
        }