public async Task UpdateSamplePlaylistShouldUpdateSamplePlaylist() { var sample = new SamplePlaylist { Id = 1 }; _projectBLMock.Setup(x => x.UpdateSamplePlaylistAsync(It.IsAny <SamplePlaylist>())).Returns(Task.FromResult(sample)); var sampleController = new SamplePlaylistController(_projectBLMock.Object); var result = await sampleController.UpdateSamplePlaylistAsync(sample.Id, sample); Assert.IsAssignableFrom <NoContentResult>(result); _projectBLMock.Verify(x => x.UpdateSamplePlaylistAsync(sample)); }
public async Task UpdateSamplePlaylistAsync_ShouldReturnStatusCode500_WhenSamplePlaylistIsInvalid() { //arrange int id = -1; SamplePlaylist samplePlaylist = null; _projectBLMock.Setup(i => i.UpdateSamplePlaylistAsync(samplePlaylist)).Throws(new Exception()); SamplePlaylistController samplePlaylistController = new SamplePlaylistController(_projectBLMock.Object); //act var result = await samplePlaylistController.UpdateSamplePlaylistAsync(id, samplePlaylist); //assert Assert.IsType <StatusCodeResult>(result); Assert.Equal(500, ((StatusCodeResult)result).StatusCode); }