public void HandleShouldAddViewingAppointment() { var property = new Models.Property { Description = "Test Property", IsListedForSale = false }; _properties.Find(1).Returns(property); var appointmentTime = new DateTime(2017, 4, 30, 12, 0, 0); var command = new MakeViewingAppointmentCommand(); command.PropertyId = 1; command.AppointmentTime = appointmentTime; command.BuyerUserId = "Test Buyer"; _handler.Handle(command); _context.Properties.Received(1).Find(1); _context.Received(1).SaveChanges(); Assert.True(property.ViewingAppointments.Count == 1); Assert.True(property.ViewingAppointments.First().AppointmentTime == appointmentTime); Assert.True(property.ViewingAppointments.First().BuyerUserId == "Test Buyer"); }
public ActionResult MakeViewingAppointment(MakeViewingAppointmentCommand command) { var handler = new MakeViewingAppointmentCommandHandler(_context); command.BuyerUserId = User.Identity.GetUserId(); handler.Handle(command); return(RedirectToAction("Index")); }