public async Task CreateAsync_OK() { // Arrange DeploymentModel deploymentModel = new DeploymentModel { TagName = "1", }; deploymentModel.Environment = new EnvironmentModel { Name = "at23", Hostname = "hostname" }; _releaseRepository.Setup(r => r.GetSucceededReleaseFromDb( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(GetReleases("updatedRelease.json").First()); _applicationInformationService.Setup(ais => ais.UpdateApplicationInformationAsync( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <EnvironmentModel>())).Returns(Task.CompletedTask); Mock <IAzureDevOpsBuildClient> azureDevOpsBuildClient = new Mock <IAzureDevOpsBuildClient>(); azureDevOpsBuildClient.Setup(b => b.QueueAsync( It.IsAny <QueueBuildParameters>(), It.IsAny <int>())).ReturnsAsync(GetBuild()); _deploymentRepository.Setup(r => r.Create( It.IsAny <DeploymentEntity>())).ReturnsAsync(GetDeployments("createdDeployment.json").First()); DeploymentService deploymentService = new DeploymentService( new TestOptionsMonitor <AzureDevOpsSettings>(GetAzureDevOpsSettings()), azureDevOpsBuildClient.Object, _httpContextAccessor.Object, _deploymentRepository.Object, _releaseRepository.Object, _applicationInformationService.Object); // Act DeploymentEntity deploymentEntity = await deploymentService.CreateAsync(deploymentModel); // Assert Assert.NotNull(deploymentEntity); _releaseRepository.Verify( r => r.GetSucceededReleaseFromDb(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); _applicationInformationService.Verify( ais => ais.UpdateApplicationInformationAsync( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <EnvironmentModel>()), Times.Once); azureDevOpsBuildClient.Verify( b => b.QueueAsync(It.IsAny <QueueBuildParameters>(), It.IsAny <int>()), Times.Once); _deploymentRepository.Verify(r => r.Create(It.IsAny <DeploymentEntity>()), Times.Once); }