public void getAllWithNoItemsReturnsNoContent() { var mockRepository = new Mock <ITrackRepository>(); mockRepository.Setup(a => a.Read()).Returns(default(IQueryable <TrackDTO>)); var controller = new TracksController(mockRepository.Object); var response = controller.Get(); Assert.IsType <NoContentResult>(response); }
public async void getGivenNoExistingIDReturnsNotFound() { var mockRepository = new Mock <ITrackRepository>(); mockRepository.Setup(a => a.Find(42)).ReturnsAsync(default(TrackDTO)); var controller = new TracksController(mockRepository.Object); var response = await controller.Get(42); Assert.IsType <NotFoundResult>(response); }
public async void getGivenExistingIDReturnsTrack() { var TrackDTO = new TrackDTO() { Id = 42 }; var mockRepository = new Mock <ITrackRepository>(); mockRepository.Setup(a => a.Find(42)).ReturnsAsync(TrackDTO); var controller = new TracksController(mockRepository.Object); var response = await controller.Get(42) as OkObjectResult; Assert.Equal(TrackDTO, response.Value); }
public async Task Get_given_id_returns_track() { var expected = new TrackDTO { Id = 5, Name = "Awesome Track" }; var mock = new Mock <ITrackRepository>(); mock.Setup(m => m.Find(5)).ReturnsAsync(expected); var controller = new TracksController(mock.Object); var actual = await controller.Get(5) as OkObjectResult; Assert.Equal(expected, actual.Value); }
public void getAllWithItemsReturnsOk() { var list = new List <TrackDTO>() { new TrackDTO() { Id = 1221 } }.AsQueryable(); var mockRepository = new Mock <ITrackRepository>(); mockRepository.Setup(a => a.Read()).Returns(list); var controller = new TracksController(mockRepository.Object); var response = controller.Get() as OkObjectResult; Assert.Equal(list, response.Value); }