Esempio n. 1
0
        internal async Task GivenCreateAsyncWhenInputIsValidThenCreatesData()
        {
            // Arrange
            mockSubscriptionService
            .Setup(_ => _.CreateAsync(It.IsAny <Subscription>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            // Act
            var result = await subscriptionController.CreateAsync(It.IsAny <Subscription>());

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

            // Act
            var result = await subscriptionController.CreateAsync(It.IsAny <Subscription>());

            // Assert
            mockSubscriptionService.VerifyAll();
            Assert.That(result, Is.InstanceOf <CreatedResult>());
            Assert.That((result as CreatedResult).StatusCode, Is.EqualTo((int)HttpStatusCode.Created));
        }