public async Task AddSamplePlaylistShouldAddSamplePlaylist() { var sample = new SamplePlaylist(); _projectBLMock.Setup(x => x.AddSamplePlaylistAsync(It.IsAny <SamplePlaylist>())).Returns(Task.FromResult <SamplePlaylist>(sample)); var sampleController = new SamplePlaylistController(_projectBLMock.Object); var result = await sampleController.AddSamplePlaylistAsync(new SamplePlaylist()); Assert.IsAssignableFrom <CreatedAtActionResult>(result); _projectBLMock.Verify(x => x.AddSamplePlaylistAsync((It.IsAny <SamplePlaylist>()))); }
public async Task AddSamplePlaylistAsync_ShouldReturnStatusCode400_WhenSamplePlaylistIsInvalid() { //arrange SamplePlaylist samplePlaylist = null; _projectBLMock.Setup(i => i.AddSamplePlaylistAsync(samplePlaylist)).Throws(new Exception()); SamplePlaylistController samplePlaylistController = new SamplePlaylistController(_projectBLMock.Object); //act var result = await samplePlaylistController.AddSamplePlaylistAsync(samplePlaylist); //assert Assert.IsType <StatusCodeResult>(result); Assert.Equal(400, ((StatusCodeResult)result).StatusCode); }