Exemple #1
0
        public void AddTourVariantSuccessful()
        {
            mockMapper.Setup(x => x.Map <TourVariant>(It.IsAny <TourVariantPostRequest>())).Returns(fixture.TourVariant);
            mockMapper.Setup(x => x.Map <TourVariantDto>(It.IsAny <TourVariant>())).Returns(fixture.TourVariantDto);

            mockUnit.Setup(x => x.TourVariants.Create(It.IsAny <TourVariant>()));
            mockUnit.Setup(x => x.Save());

            var result = service.AddTourVariant(fixture.TourVariantPostRequest);

            mockMapper.VerifyAll();
            mockUnit.VerifyAll();
            Assert.True(result == fixture.TourVariantDto);
        }
        public IHttpActionResult AddTourVariant(TourVariantPostRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var tourVariant = tourVariantService.AddTourVariant(request);

            return(Created(Url.Link("GetTourVariant", new { id = tourVariant.Id }), tourVariant));
        }