public async Task GetSamplePlaylistByIDAsync_ShouldReturnNotFound_whenIDIsInvalid() { //arrange int id = -1; _projectBLMock.Setup(i => i.GetSampleByIDAsync(id)).Throws(new Exception()); SamplePlaylistController samplePlaylistController = new SamplePlaylistController(_projectBLMock.Object); //act var result = await samplePlaylistController.GetSamplePlaylistByIDAsync(id); //assert Assert.IsType <NotFoundResult>(result); }
public async Task GetSamplePlaylistByIdShouldGetSample() { var sampleId = 1; var sample = new SamplePlaylist { Id = sampleId }; _projectBLMock.Setup(x => x.GetSamplePlaylistByIDAsync(It.IsAny <int>())).Returns(Task.FromResult(sample)); var sampleController = new SamplePlaylistController(_projectBLMock.Object); var result = await sampleController.GetSamplePlaylistByIDAsync(sampleId); Assert.Equal(sampleId, ((SamplePlaylist)((OkObjectResult)result).Value).Id); _projectBLMock.Verify(x => x.GetSamplePlaylistByIDAsync(sampleId)); }