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 GetTheParametersOfJSONDllTestOk() { ReflectionLogic reflectionLogic = new ReflectionLogic(); List <Parameter> parametersOfImporterJson = reflectionLogic.GetTheParametersRequired("\\Importers\\ImporterJson.dll"); JsonImporter importerJson = new JsonImporter(); CollectionAssert.AreEqual(importerJson.GetParameter(), parametersOfImporterJson); }
public void GetTheParametersOfXmlDllTestOk() { ReflectionLogic reflectionLogic = new ReflectionLogic(); List <Parameter> parametersOfImporterXml = reflectionLogic.GetTheParametersRequired("\\Importers\\ImporterXml.dll"); XmlImporter importerXml = new XmlImporter(); CollectionAssert.AreEqual(importerXml.GetParameter(), parametersOfImporterXml); }
public void GettingAvailablesImporterOk() { ReflectionLogic reflectionLogic = new ReflectionLogic(); List <IImport> listOfDllObteined = reflectionLogic.GetAvailableImporters().ToList(); bool resultOfValuesObteined = listOfDllObteined[0].GetName().Equals("Importador JSON") && listOfDllObteined[1].GetName().Equals("Importador XML"); Assert.IsTrue(resultOfValuesObteined); }
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 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 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 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); }
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 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 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 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]); }
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 FailInGetParametersOfJsonDllWithoutConstructorTest() { ReflectionLogic reflectionLogic = new ReflectionLogic(); List <Parameter> parametersOfImporterJson = reflectionLogic.GetTheParametersRequired("\\ImporterWithoutConstructor\\ImporterJsonWithoutConstructor.dll"); }
public ImporterController(ILodgingManagementForImportation lodgingLogic, ReflectionLogic logicOfReflection) { lodgingManagement = lodgingLogic; reflectionLogic = logicOfReflection; }