public async Task GetAll_Sucess() { var mock = new Mock <ITripService>(); TripsController controller = new TripsController(mock.Object); var result = await controller.GetAll(); mock.Verify(service => service.GetAllAsync(), Times.AtLeastOnce()); }
public void ShouldReturnAllTrips() { var ctrlr = new TripsController(TripManager); var result = ctrlr.GetAll().ToList(); Assert.That(result, Is.EqualTo(Trips.Values.Select(t => new TripWithId { Id = t.Id, StartDate = t.StartDate, EndDate = t.EndDate, Destination = t.Destination, Comment = t.Comment }).ToList())); }
public async Task GetAll_Sucess() { var mockRepository = new Mock <ITripRepository>(); mockRepository.Setup(repository => repository.GetAllAsync()).Returns(Task.FromResult(new List <Trip>())); var mockUnit = new Mock <IUnitOfWork>(); TripService TripService = new TripService(mockUnit.Object, mockRepository.Object); TripsController controller = new TripsController(TripService); var result = await controller.GetAll(); mockRepository.Verify(repository => repository.GetAllAsync(), Times.AtLeastOnce()); Assert.IsInstanceOfType(result, typeof(ActionResult <IEnumerable <TripDto> >)); }