public async Task GivenCreateAsyncWhenInputIsValidThenCreatesData()
        {
            // Arrange
            mockVideoService
            .Setup(_ => _.CreateAsync(It.IsAny <Video>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await videoController.CreateAsync(It.IsAny <Video>());

            // Assert
            mockVideoService.VerifyAll();
            Assert.That(result, Is.InstanceOf <CreatedResult>());
            Assert.That((result as CreatedResult).StatusCode, Is.EqualTo((int)HttpStatusCode.Created));
        }
Пример #2
0
        public async Task GivenCreateAsyncWhenInputIsValidThenCreatesData()
        {
            // Arrange
            mockVideoService
            .Setup(_ => _.CreateAsync(It.IsAny <Video>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await videoController.CreateAsync(It.IsAny <Video>());

            // Assert
            mockVideoService.VerifyAll();
            result.Should().NotBeNull().And.BeOfType <CreatedResult>();
            (result as CreatedResult).StatusCode.Should().Be((int)HttpStatusCode.Created);
        }
        internal async Task GivenCreateAsyncWhenInputIsValidThenCreatesData()
        {
            // Arrange
            mockVideoService
            .Setup(_ => _.CreateAsync(It.IsAny <Video>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await videoController.CreateAsync(It.IsAny <Video>());

            // Assert
            mockVideoService.VerifyAll();
            Assert.IsType <CreatedResult>(result);
            Assert.Equal((int)HttpStatusCode.Created, (result as CreatedResult).StatusCode);
        }