public void TestPostOfOk() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); lodgingManagementForImportationMock.Setup(m => m.Create(It.IsAny <Lodging>(), It.IsAny <TouristSpot>(), It.IsAny <List <string> >())).Returns(It.IsAny <Lodging>()); ReflectionLogic reflectionLogic = new ReflectionLogic(); ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); string sourcePathJson = "\\Importers\\ImporterJson.dll"; List <Parameter> listOfParameters = new List <Parameter>() { new Parameter() { Name = "pathOfJsonFile", Type = "file", Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\Lodgings.json" } }; var result = importerController.Post(listOfParameters, sourcePathJson); var createdResult = result as OkObjectResult; var model = createdResult.Value as string; lodgingManagementForImportationMock.VerifyAll(); Assert.AreEqual("Todos los hospedajes fueron agregados al sistema.", model); }
public void FailInTestOfPostLodgings() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); lodgingManagementForImportationMock.Setup(m => m.Create(It.IsAny <Lodging>(), It.IsAny <TouristSpot>(), It.IsAny <List <string> >())).Throws(new Exception()); ReflectionLogic reflectionLogic = new ReflectionLogic(); ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); string sourcePathJson = "\\Importers\\ImporterJson.dll"; List <Parameter> listOfParameters = new List <Parameter>() { new Parameter() { Name = "pathOfJsonFile", Type = "file", Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\Lodgings.json" } }; var result = importerController.Post(listOfParameters, sourcePathJson); var createdResult = result as BadRequestObjectResult; lodgingManagementForImportationMock.VerifyAll(); Assert.AreEqual(400, createdResult.StatusCode); }
public void ProcessRequest(HttpContext context) { // ensure the latest content has been processed & imported ImporterController.ImportDocModelsRunOnce(); Regex regPublishUrl = new Regex("(?<=publishUrl=\")(.*?)(?=\")", RegexOptions.Multiline); // The publish URL within this file needs to be updated to the current requested URL for the InfoPath application form to like it //string ManifestPath = context.Request.MapPath(new Uri(RequestPaths.AbsoluteUri).LocalPath); string UrlReferrer_AbsoluteUri = context.Request.UrlReferrer == null ? "" : context.Request.UrlReferrer.AbsoluteUri; string filename; string[] lines = TemplateController.Instance.OpenText(context, out filename).Split('\n', '\r'); // render the publishUrl as the calling request or that of a registered listener string publishUrl = UrlReferrer_AbsoluteUri.Contains("/" + DCF_Relay.DCF_Relay.DirectoryName) ? UrlReferrer_AbsoluteUri : RequestPaths.AbsoluteUri; context.Response.ClearContent(); for (int i = 0; i < lines.Length; i++) { context.Response.Write( regPublishUrl.IsMatch(lines[i]) ? regPublishUrl.Replace(lines[i], publishUrl) : lines[i]); } context.Response.ContentType = "text/xml"; }
public ImporterControllerTests() { this.mediator = A.Fake <IMediator>(); this.auditService = A.Fake <IAuditService>(); importerController = new ImporterController(A.Fake <IMediator>(), A.Fake <IMapWithParameter <ImporterViewModel, AddressRecordType, AddAddressBookEntry> >(), this.auditService); A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.Importer)); }
public ImporterControllerTests() { _validatorMock = new Mock <IValidator>(); _responseFactory = new Mock <IResponseFactory>(); _csvImporterService = new Mock <ICsvImporterService>(); _jobServiceMock = new Mock <IJobsService>(); _importerController = new ImporterController(_validatorMock.Object, _responseFactory.Object, _csvImporterService.Object, _jobServiceMock.Object); }
public void GetImportersTestOk() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); ReflectionLogic reflectionLogic = new ReflectionLogic(); ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); var result = importerController.Get(); var createdResult = result as OkObjectResult; var model = createdResult.Value as List <string>; lodgingManagementForImportationMock.VerifyAll(); Assert.IsTrue(model[0].Equals("Importador JSON") && model[1].Equals("Importador XML")); }
public void GetParametersOfJsonDllExceptionTest() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); ReflectionLogic reflectionLogic = new ReflectionLogic(); ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); string sourcePathJson = Directory.GetCurrentDirectory() + "\\Importers\\ImporterDrive"; var result = importerController.GetParameters(sourcePathJson); var createdResult = result as ObjectResult; lodgingManagementForImportationMock.VerifyAll(); Assert.AreEqual(500, createdResult.StatusCode); }
public void GetFailInGetImportersTest() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); ReflectionLogic reflectionLogic = new ReflectionLogic(); reflectionLogic.PathOfWhereAreImporters = Directory.GetCurrentDirectory() + "\\FilesToImport"; ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); var result = importerController.Get(); var createdResult = result as NotFoundObjectResult; lodgingManagementForImportationMock.VerifyAll(); Assert.AreEqual(404, createdResult.StatusCode); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Task.Factory.StartNew(() => { ImporterController.ImportDocModelsRunOnce(); ImporterController.ImportFolder(); // make sure all the DOCREV (document templates) have been processed & are known before the rest of the import folder's content are processed as they will depend on there owner doc templates to be processed themselves foreach (string folderName in Directory.EnumerateDirectories(FilesystemTemplateController.DirectoryPath)) { ImporterController.ImportContentFolder(folderName); } }); } }
public void GetParametersOfJsonDllOkTest() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); ReflectionLogic reflectionLogic = new ReflectionLogic(); ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); string sourcePathJson = "\\Importers\\ImporterJson.dll"; var result = importerController.GetParameters(sourcePathJson); var createdResult = result as OkObjectResult; var model = createdResult.Value as List <Parameter>; lodgingManagementForImportationMock.VerifyAll(); Assert.IsTrue(model[0].Name.Equals("pathOfJsonFile") && model[0].Type.Equals("file")); }
public void FailInTestOfPostLodgingsBecauseHaveAExceptionImportingLodgings() { var lodgingManagementForImportationMock = new Mock <ILodgingManagementForImportation>(MockBehavior.Strict); ReflectionLogic reflectionLogic = new ReflectionLogic(); ImporterController importerController = new ImporterController(lodgingManagementForImportationMock.Object, reflectionLogic); string sourcePathJson = Directory.GetCurrentDirectory() + "\\Importers\\ImporterJsonWithoutConstructor.dll"; List <Parameter> listOfParameters = new List <Parameter>() { new Parameter() { Name = "pathOfJsonFile", Type = "file", Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\LodgingsV4.json" } }; var result = importerController.Post(listOfParameters, sourcePathJson); var createdResult = result as ObjectResult; Assert.AreEqual(500, createdResult.StatusCode); }
public void TryDocRevImportingTest() { ImporterController.TryDocRevImporting(); }
public virtual void ProcessRequest(HttpContext context) { // ensure the latest content has been processed & imported ImporterController.TryDocRevImporting(); TemplateFileInfo _TemplateFileInfo = TemplateController.ParseTemplateFileInfo(context); if (!string.IsNullOrWhiteSpace(_TemplateFileInfo.DocTypeName) && !string.IsNullOrWhiteSpace(_TemplateFileInfo.solutionVersion) && !string.IsNullOrWhiteSpace(_TemplateFileInfo.FileName)) { // serve a supporting template file up (the the target Interpreter may need to alter it in some way, qazi-dynamic) InstanceLocatorByName <DocBaseInterpreter>(_TemplateFileInfo.DocTypeName, _TemplateFileInfo.solutionVersion) .ProcessRequest(context); } else { // serve a filled & stored document rendered previously context.Response.DisableKernelCache(); context.Response.Clear(); context.Response.ClearContent(); context.Response.ClearHeaders(); object docData; if (context.Request.Params.AllKeys.Any(m => m == Parm.DocId.ToString())) { docData = DocExchange.LuceneController.GetDocData( context.Request.Params[Parm.DocTypeName], context.Request.Params[Parm.DocId], HttpUtility.UrlDecode(context.Request.Params[Parm.RelayUrl]), long.Parse(context.Request.Params[Parm.LogSequenceNumber] ?? "0")); } else { docData = ((BaseDoc)(context.Request.Params.AllKeys.Any(m => m == Parm.DocCache) ? HttpRuntime.Cache[context.Request.Params[Parm.DocCache]] : Compressor.DecompressFromBase64String(HttpUtility.UrlDecode(context.Request.Params[Parm.DocBin])) .FromBytes <BaseDoc>())); } DocBaseInterpreter _DocBaseInterpreter = null; DocProcessingInstructions _DocProcessingInstructions; //TODO:need to tidy up this code block as its really hard to follow.. In the end, that docData may be a POCO, raw bytes or text... Need to rewrites it's PI here before it's shoved over the repsonse.stream if (docData is BaseDoc) { // get the interpreter & convert docData from poco to its raw form _DocBaseInterpreter = InstanceLocatorByName <DocBaseInterpreter>(((BaseDoc)docData).DocTypeName, ((BaseDoc)docData).solutionVersion); if (_DocBaseInterpreter is DocByteInterpreter) { docData = ((DocByteInterpreter)_DocBaseInterpreter).WriteByte((BaseDoc)docData); } else { docData = ((DocTextInterpreter)_DocBaseInterpreter).WriteText((BaseDoc)docData); } } if (docData is byte[]) { _DocBaseInterpreter = _DocBaseInterpreter ?? LocateInstance((byte[])docData); _DocProcessingInstructions = Instance.ReadDocPI((byte[])docData); docData = Instance.ModPI((byte[])docData, href: DocBaseInterpreter.BuildHref(context, _DocProcessingInstructions.DocTypeName, _DocProcessingInstructions.solutionVersion)); context.Response.BinaryWrite((byte[])docData); } else { _DocBaseInterpreter = _DocBaseInterpreter ?? LocateInstance((string)docData); _DocProcessingInstructions = Instance.ReadDocPI((string)docData); docData = Instance.ModPI((string)docData, href: DocBaseInterpreter.BuildHref(context, _DocProcessingInstructions.DocTypeName, _DocProcessingInstructions.solutionVersion)); context.Response.Write((string)docData); } context.Response.ContentType = _DocBaseInterpreter.ContentInfo.ContentType; context.Response.AddHeader( "content-disposition", string.Format( "attachment; filename=\"{0}\";", DocBaseInterpreter.GetFilename(_DocProcessingInstructions, context.Request.Params["ContentFileExtension"]))); } }
public ImporterControllerTests() { importerController = new ImporterController(A.Fake<IMediator>(), A.Fake<IMapWithParameter<ImporterViewModel, AddressRecordType, AddAddressBookEntry>>()); }