public void PostLodgingReturnsValidModel()
        {
            var lodging         = LodgingModel.ToEntity();
            var lodgingToReturn = LodgingModel.ToEntity();

            lodgingToReturn.TouristSpot.Region = new Region()
            {
                Id   = 3,
                Name = "region"
            };
            lodgingToReturn.TouristSpot.TouristSpotCategories = new List <TouristSpotCategory>();

            LodgingLogicMock.Setup(m => m.Create(lodging)).Returns(lodgingToReturn);

            var result  = LodgingController.Post(LodgingModel) as CreatedResult;
            var content = result.Value as LodgingBasicInfoModel;

            LodgingLogicMock.VerifyAll();
            Assert.IsTrue(content.Equals(new LodgingBasicInfoModel(lodgingToReturn)));
        }
        public void CreateLodgingInternalServerErrorTest()
        {
            var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict);

            lodgingManagementMock.Setup(m => m.Create(It.IsAny <Lodging>(), It.IsAny <Guid>(), It.IsAny <List <string> >())).Throws(new ServerBusinessLogicException("Error interno"));
            LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object);
            var result        = lodgingController.Post(lodgingModelForRequest);
            var createdResult = result as ObjectResult;

            lodgingManagementMock.VerifyAll();
            Assert.AreEqual(500, createdResult.StatusCode);
        }
        public void CreateLodgingWithoutTouristSpotTest()
        {
            var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict);

            lodgingManagementMock.Setup(m => m.Create(It.IsAny <Lodging>(), It.IsAny <Guid>(), It.IsAny <List <string> >())).
            Throws(new ClientBusinessLogicException("No se puede crear el hospedaje debido a que no se encontro el punto turistico"));
            LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object);
            var result        = lodgingController.Post(lodgingModelForRequest);
            var createdResult = result as NotFoundObjectResult;

            lodgingManagementMock.VerifyAll();
            Assert.AreEqual(404, createdResult.StatusCode);
        }
        public void CreateLodgingInvalidTest()
        {
            var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict);

            lodgingManagementMock.Setup(m => m.Create(It.IsAny <Lodging>(), It.IsAny <Guid>(), It.IsAny <List <string> >())).
            Throws(new DomainBusinessLogicException("No se puede crear el hospedaje debido a que no es valido."));
            LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object);
            var result        = lodgingController.Post(lodgingModelForRequest);
            var createdResult = result as BadRequestObjectResult;

            lodgingManagementMock.VerifyAll();
            Assert.AreEqual(400, createdResult.StatusCode);
        }
        public void CreateLodgingTestOk()
        {
            var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict);

            lodgingManagementMock.Setup(m => m.Create(It.IsAny <Lodging>(), It.IsAny <Guid>(), It.IsAny <List <string> >())).Returns(lodgingOfficial);
            LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object);
            var result        = lodgingController.Post(lodgingModelForRequest);
            var createdResult = result as CreatedAtRouteResult;
            var model         = createdResult.Value as LodgingModelForSearchResponse;

            lodgingManagementMock.VerifyAll();
            Assert.AreEqual(LodgingModelForSearchResponse.ToModel(lodgingOfficial), model);
        }
        public async void TestControllerPost()
        {
            var resultPass = await _controller.Post(new LodgingModel());

            Assert.NotNull(resultPass);
        }