public void AddTourSuccessful() { mockMapper.Setup(x => x.Map <Tour>(It.IsAny <TourPostRequest>())).Returns(fixture.Tour); mockMapper.Setup(x => x.Map <TourDto>(It.IsAny <Tour>())).Returns(fixture.TourDto); mockUnit.Setup(x => x.Tours.Create(It.IsAny <Tour>())); mockUnit.Setup(x => x.Save()); var result = service.AddTour(fixture.TourPostRequest); mockMapper.VerifyAll(); mockUnit.VerifyAll(); Assert.True(result == fixture.TourDto); }
public IHttpActionResult AddTour(TourPostRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var tour = toursService.AddTour(request); return(Created(Url.Link("GetTour", new { id = tour.Id }), tour)); }