Esempio n. 1
0
        public void AddTour_CapableAction()
        {
            TourDTO tourDTO = new TourDTO()
            {
                Name = "Action", TourTypeId = 1, InfoId = 2
            };

            mock.Setup(m => m.Tours.GetAll()).Returns(tours);
            mock.Setup(m => m.TourTypes.Get(tourDTO.TourTypeId)).Returns(type);
            mock.Setup(m => m.TourInfos.Get(tourDTO.InfoId)).Returns(info);
            TourService tourService = new TourService(mock.Object);

            tourService.MakeTour((tourDTO));

            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <TourDTO, Tour>()).CreateMapper();
            var tour   = mapper.Map <TourDTO, Tour>(tourDTO);

            tours.Add(tour);//tours.Append(tour);

            mock.Verify(lw => lw.Tours.Create(It.IsAny <Tour>()),
                        Times.Once());
            Assert.That(tours.Count(), Is.EqualTo(6));
        }