Exemplo n.º 1
0
        public IHttpActionResult GetAllTrips()
        {
            TripService tripService = CreateTripService();
            var         trips       = tripService.GetAllTrips();

            return(Ok(trips));
        }
Exemplo n.º 2
0
        public void Test_GetAllTrips_Success()
        {
            // Act
            _tripService.GetAllTrips();

            // Assert
            _mockTripRepository.Verify(m => m.GetAllTrips(), Times.Once());
        }
        public void BeCalled_WhenParamsAreValid()
        {
            //Arrange
            var mockedRepository = new Mock <IEFRepository <Trip> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var tripService      = new TripService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            tripService.GetAllTrips();

            //Assert
            mockedRepository.Verify(repository => repository.All(), Times.Once);
        }
        public void ThrowException_WhenNullTrip()
        {
            //Arrange
            var mockedRepository = new Mock <IEFRepository <Trip> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var tripService      = new TripService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            IEnumerable <Trip> result = null;

            mockedRepository.Setup(repository => repository.All()).Returns(() => result.AsQueryable());

            //Assert
            Assert.Throws <ArgumentNullException>(() => tripService.GetAllTrips());
        }
        public void ReturnEmptyCollection_WhenNoDestinations()
        {
            //Arrange
            var mockedRepository = new Mock <IEFRepository <Trip> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var tripService      = new TripService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            IEnumerable <Trip> result = new List <Trip>();

            mockedRepository.Setup(repository => repository.All()).Returns(() => result.AsQueryable());

            //Assert
            Assert.IsEmpty(tripService.GetAllTrips());
        }
        public void WorksProperly_WhenInvoked()
        {
            //Arrange
            var mockedRepository = new Mock <IEFRepository <Trip> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var tripService      = new TripService(mockedRepository.Object, mockedUnitOfWork.Object);

            //Act
            IEnumerable <Trip> result = new List <Trip>()
            {
                new Trip(), new Trip(), new Trip()
            };

            mockedRepository.Setup(repository => repository.All()).Returns(() => result.AsQueryable());

            //Assert
            Assert.AreEqual(tripService.GetAllTrips(), result);
        }
Exemplo n.º 7
0
 public IEnumerable <Trip> GetTripsList()
 {
     return(TripService.GetAllTrips());
 }
Exemplo n.º 8
0
        public ActionResult <List <Trip> > GetAllTrips()
        {
            string id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            return(_tripService.GetAllTrips(id));
        }