コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }