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