public void FailInImportLodgingWithMoreParametersInJsonDllTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); List <Parameter> listOfParameters = reflectionLogic.GetTheParametersRequired("\\Importers\\ImporterJson.dll"); listOfParameters[0].Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\Lodgings.json"; listOfParameters.Add(new Parameter()); reflectionLogic.ImportLodgings("\\Importers\\ImporterJson.dll", listOfParameters); }
public void FailInImportLodgingWithMoreParametersInXmlDllTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfXmlDll = "\\Importers\\ImporterXml.dll"; List <Parameter> listOfParameters = reflectionLogic.GetTheParametersRequired(pathOfXmlDll); listOfParameters[0].Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\Lodgings.xml"; listOfParameters.Add(new Parameter()); reflectionLogic.ImportLodgings(pathOfXmlDll, listOfParameters); }
public void FailInImportLodgingWithInvalidOperationInXMLFileTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfXmlDll = "\\Importers\\ImporterXml.dll"; List <Parameter> listOfParametersExpected = new List <Parameter>() { new Parameter() { Name = "pathOfXmlFile", Type = "file", Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\LodgingsV2.xml" } }; reflectionLogic.ImportLodgings(pathOfXmlDll, listOfParametersExpected); }
public void FailInImportLodgingWithReadErrorInJSONFileTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfDll = "\\Importers\\ImporterJson.dll"; List <Parameter> listOfParametersExpected = new List <Parameter>() { new Parameter() { Name = "pathOfJsonFile", Type = "file", Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\LodgingsV3.json" } }; reflectionLogic.ImportLodgings(pathOfDll, listOfParametersExpected); }
public void FailInImportLodgingWrongPathOfDirectoryXMLDllTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfXmlDll = "\\Importers\\ImporterXml.dll"; List <Parameter> listOfParametersExpected = new List <Parameter>() { new Parameter() { Name = "pathOfJsonFile", Type = "file", Value = Directory.GetCurrentDirectory() + "\\FilesToImpor\\Lodgings.json" } }; reflectionLogic.ImportLodgings(pathOfXmlDll, listOfParametersExpected); }
public void FailInImportLodgingNullPathOfFileXmlDllTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfXmlDll = "\\Importers\\ImporterXml.dll"; List <Parameter> listOfParametersExpected = new List <Parameter>() { new Parameter() { Name = "pathOfXmlFile", Type = "file", Value = null } }; reflectionLogic.ImportLodgings(pathOfXmlDll, listOfParametersExpected); }
public void FailInImportLodgingEmptyPathOfFileJsonDllTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfDll = "\\Importers\\ImporterJson.dll"; List <Parameter> listOfParametersExpected = new List <Parameter>() { new Parameter() { Name = "pathOfJsonFile", Type = "file", Value = "" } }; reflectionLogic.ImportLodgings(pathOfDll, listOfParametersExpected); }
public IActionResult Post([FromBody] List <Parameter> informationForTheImporters, [FromQuery] string pathOfDll) { List <LodgingModelForImport> lodgingsNotCreated = new List <LodgingModelForImport>(); try { List <LodgingModelForImport> lodgingsImported = reflectionLogic.ImportLodgings(pathOfDll, informationForTheImporters); foreach (LodgingModelForImport lodging in lodgingsImported) { try { lodgingManagement.Create(lodging.ToEntity(), lodging.TouristSpot.ToEntity(), lodging.Images); }catch (Exception) { lodgingsNotCreated.Add(lodging); } } if (lodgingsNotCreated.IsNullOrEmpty() && !lodgingsImported.IsNullOrEmpty()) { return(Ok("Todos los hospedajes fueron agregados al sistema.")); } else if (lodgingsImported.IsNullOrEmpty()) { return(BadRequest("No se importaron hospedajes.")); } else { return(BadRequest(lodgingsNotCreated)); } } catch (ImportationException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public void ImportingLodgingsTestOfXmlDllOk() { ReflectionLogic reflectionLogic = new ReflectionLogic(); string pathOfXmlDll = "\\Importers\\ImporterXml.dll"; List <Parameter> listOfParameters = reflectionLogic.GetTheParametersRequired(pathOfXmlDll); listOfParameters[0].Value = Directory.GetCurrentDirectory() + "\\FilesToImport\\Lodgings.xml"; List <LodgingModelForImport> lodgingsImported = reflectionLogic.ImportLodgings(pathOfXmlDll, listOfParameters); TouristSpotModelForImport touristSpotModel = new TouristSpotModelForImport() { Id = new Guid("7cb8a7ab-8511-473f-803f-6b39118e79c1"), Name = "Punta del Este", Description = "La naturaleza abunda", RegionId = new Guid("fc775bb9-8cc8-4fdc-bca6-16e06bcd322b"), ImagePath = "Desktop\\pde.jpg", ListOfCategoriesId = new List <Guid>() { new Guid("baa98b33-eafe-4d62-bb62-859a8e36d3a9") } }; LodgingModelForImport lodgingModelForImport = new LodgingModelForImport() { Name = "Hotel Enjoy Conrad", Description = "Un lugar magico donde podes vivir.", QuantityOfStars = 5, Address = "Playa Mansa parada 21", Images = new List <string>() { "Desktop\\conrad.jpg" }, PricePerNight = 200.0, IsAvailable = true, TouristSpot = touristSpotModel }; Assert.AreEqual(lodgingModelForImport, lodgingsImported[0]); }