public void AppointmentPartial_Get_BadId_WhenCalled_Returns_NotFound() { var propertyId = "1"; PropertyMessagesViewModel mess = new PropertyMessagesViewModel(); mess.Id = propertyId; var result = _controller.MessagePartial(propertyId); Assert.AreEqual(((HttpStatusCodeResult)result).StatusCode, (int)HttpStatusCode.NotFound); }
public void MessagePartial_Get_WhenCalled_Returns_Messages_PartialView() { var propertyId = "1"; PropertyMessagesViewModel mess = new PropertyMessagesViewModel(); mess.Id = propertyId; _mockRepository.Setup(r => r.GetMessagesByPropertyId(propertyId)).Returns(mess.messages); var result = _controller.MessagePartial(propertyId); result.Should().NotBeNull(); }
public ActionResult MessagePartial(string id) { PropertyMessagesViewModel viewModel = new PropertyMessagesViewModel(); HomeFindingProperty property = getPropertyById(id); if (property == null) { return(HttpNotFound()); } viewModel.messages = GetMessagesByPropertyId(property.Id); if (viewModel.messages == null) { return(HttpNotFound()); } if (viewModel.messages.Count() > 0) { viewModel.latest = viewModel.messages.First().MessageDate; } viewModel.Id = property.Id; var userId = User.Identity.GetUserId(); ViewBag.CurrentUser = userId; return(PartialView("~/views/Orders/Partials/_Message.cshtml", viewModel)); }