internal async Task GivenCreateAsyncWhenInputIsValidThenCreatesData() { // Arrange mockPlaylistService .Setup(_ => _.CreateAsync(It.IsAny <Playlist>())) .Returns(Task.CompletedTask) .Verifiable(); // Act var result = await playlistController.CreateAsync(It.IsAny <Playlist>()); // Assert mockPlaylistService.VerifyAll(); Assert.IsType <CreatedResult>(result); Assert.Equal((int)HttpStatusCode.Created, (result as CreatedResult).StatusCode); }
public async Task GivenCreateAsyncWhenInputIsValidThenCreatesData() { // Arrange mockPlaylistService .Setup(_ => _.CreateAsync(It.IsAny <Playlist>())) .Returns(Task.CompletedTask) .Verifiable(); // Act var result = await playlistController.CreateAsync(It.IsAny <Playlist>()); // Assert mockPlaylistService.VerifyAll(); Assert.That(result, Is.InstanceOf <CreatedResult>()); Assert.That((result as CreatedResult).StatusCode, Is.EqualTo((int)HttpStatusCode.Created)); }
public async Task GivenCreateAsyncWhenInputIsValidThenCreatesData() { // Arrange mockPlaylistService .Setup(_ => _.CreateAsync(It.IsAny <Playlist>())) .Returns(Task.CompletedTask) .Verifiable(); // Act var result = await playlistController.CreateAsync(It.IsAny <Playlist>()); // Assert mockPlaylistService.VerifyAll(); result.Should().NotBeNull().And.BeOfType <CreatedResult>(); (result as CreatedResult).StatusCode.Should().Be((int)HttpStatusCode.Created); }