public ActionResult Addtrip(TripVm trip) { var tripService = new TripService(); tripService.AddTrip(trip, User.Identity.Name); return(RedirectToAction("Index")); }
public ActionResult AddTrip(string trip_name, int trip_price, string customer_name, int trip_days, string trip_date, string custom_require, int customer_count, string remark) { TripService.AddTrip(trip_name, trip_price, customer_name, trip_days, trip_date, custom_require, remark, customer_count); return(RedirectToAction("Index")); }
public void ThrowException_WhenTripIsInvalid() { //Arrange var mockedRepository = new Mock <IEFRepository <Trip> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var tripService = new TripService(mockedRepository.Object, mockedUnitOfWork.Object); Mock <Trip> trip = null; //Act & Assert Assert.Throws <NullReferenceException>(() => tripService.AddTrip(trip.Object)); }
public void CallSaveChangesOnce_WhenTripIsValid() { //Arrange var mockedRepository = new Mock <IEFRepository <Trip> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var tripService = new TripService(mockedRepository.Object, mockedUnitOfWork.Object); var trip = new Mock <Trip>(); //Act tripService.AddTrip(trip.Object); //Assert mockedUnitOfWork.Verify(unit => unit.SaveChanges(), Times.Once); }
public void BeInvokeOnceForTypeTrip_WhenParamsAreCorrect() { //Arrange var mockedRepository = new Mock <IEFRepository <Trip> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var tripService = new TripService(mockedRepository.Object, mockedUnitOfWork.Object); var trip = new Mock <Trip>(); //Act tripService.AddTrip(trip.Object); //Assert mockedRepository.Verify(repository => repository.Add(It.IsAny <Trip>()), Times.Once); }
public void BeInvoked_WhenTripIsValid() { //Arrange var mockedRepository = new Mock <IEFRepository <Trip> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var tripService = new TripService(mockedRepository.Object, mockedUnitOfWork.Object); var trip = new Mock <Trip>(); //Act tripService.AddTrip(trip.Object); //Assert mockedRepository.Verify(repository => repository.Add(trip.Object)); }
public void Test_AddTrip_Success() { // Arrange var trip = new Trip { Name = "TripName", Description = "TripDescription", DateCompleted = new DateTime(2020, 1, 2), DateStarted = new DateTime(2019, 1, 2) }; // Act _tripService.AddTrip(trip); // Assert _mockTripRepository.Verify(m => m.AddTrip(trip), Times.Once()); }
public async void AddTrip() { var repo = new Mock <ITripRepository> (); var uow = new Mock <IUnitOfWork> (); string lineID = "Line:1"; string pathID = "Path:1"; string tripDepartureTime = "20:12:10"; var trip = new Trip(lineID, pathID, tripDepartureTime); var tripDTO = new TripDTO(trip.Id.AsGuid(), new LineId(lineID), new PathId(pathID), tripDepartureTime); var creatingTrip = new CreatingTripDTO(lineID, pathID, tripDepartureTime); repo.Setup(_ => _.AddAsync(trip)).ReturnsAsync(trip); var service = new TripService(repo.Object, uow.Object); var actual = await service.AddTrip(creatingTrip, new List <CreatingNodePassageDTO> ()); Assert.Equal(tripDTO, actual); }
public void Post([FromBody] TripDTO value) { _service.AddTrip(value, User.Identity.Name); }