public async Task DeleteAsync_ShouldReturnNotFoundResponseGivenTheIdDoesNotMatchAChannel()
        {
            var nonExistentId = new Fixture().Create <int>();

            _channelService.Setup(x => x.ExistsAsync(nonExistentId)).ReturnsAsync(false);

            var result = await _controller.DeleteAsync(nonExistentId);

            result.Should().BeOfType <NotFoundResult>();
        }
        internal async Task GivenDeleteAsyncWhenDataExistThenDeletesData()
        {
            // Arrange
            mockChannelService
            .Setup(_ => _.DeleteAsync(It.IsAny <int>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await channelController.DeleteAsync(It.IsAny <int>());

            // Assert
            mockChannelService.VerifyAll();
            Assert.IsType <NoContentResult>(result);
            Assert.Equal((int)HttpStatusCode.NoContent, (result as NoContentResult).StatusCode);
        }
        public async Task GivenDeleteAsyncWhenDataExistThenDeletesData()
        {
            // Arrange
            mockChannelService
            .Setup(_ => _.DeleteAsync(It.IsAny <int>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await channelController.DeleteAsync(It.IsAny <int>());

            // Assert
            mockChannelService.VerifyAll();
            Assert.That(result, Is.InstanceOf <NoContentResult>());
            Assert.That((result as NoContentResult).StatusCode, Is.EqualTo((int)HttpStatusCode.NoContent));
        }
Esempio n. 4
0
        public async Task GivenDeleteAsyncWhenDataExistThenDeletesData()
        {
            // Arrange
            mockChannelService
            .Setup(_ => _.DeleteAsync(It.IsAny <int>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await channelController.DeleteAsync(It.IsAny <int>());

            // Assert
            mockChannelService.VerifyAll();
            result.Should().NotBeNull().And.BeOfType <NoContentResult>();
            (result as NoContentResult).StatusCode.Should().Be((int)HttpStatusCode.NoContent);
        }