예제 #1
0
        public async void ReconcileAsyncAbortsWhenConfigSourceReturnsKnownExceptions(
            Exception testException,
            DeploymentStatusCode statusCode)
        {
            // Arrange
            var mockConfigSource = new Mock <IConfigSource>();
            var mockEnvironment  = new Mock <IEnvironment>();
            var mockPlanner      = new Mock <IPlanner>();
            var mockPlanRunner   = new Mock <IPlanRunner>();
            var mockReporter     = new Mock <IReporter>();
            var token            = default(CancellationToken);
            var currentSet       = ModuleSet.Empty;
            var mockModuleIdentityLifecycleManager = new Mock <IModuleIdentityLifecycleManager>();
            var configStore             = Mock.Of <IEntityStore <string, string> >();
            var mockEnvironmentProvider = Mock.Of <IEnvironmentProvider>(m => m.Create(It.IsAny <DeploymentConfig>()) == mockEnvironment.Object);
            var serde = Mock.Of <ISerde <DeploymentConfigInfo> >();
            var encryptionDecryptionProvider = Mock.Of <IEncryptionProvider>();
            var availabilityMetric           = Mock.Of <IAvailabilityMetric>();

            var deploymentConfigInfo = new DeploymentConfigInfo(10, testException);

            mockConfigSource.Setup(cs => cs.GetDeploymentConfigInfoAsync())
            .ReturnsAsync(deploymentConfigInfo);
            mockEnvironment.Setup(env => env.GetModulesAsync(token))
            .ReturnsAsync(currentSet);
            mockReporter.Setup(r => r.ReportAsync(token, It.IsAny <ModuleSet>(), It.IsAny <IRuntimeInfo>(), It.IsAny <long>(), It.Is <DeploymentStatus>(s => s.Code == statusCode)))
            .Returns(Task.CompletedTask);

            var agent = new Agent(mockConfigSource.Object, mockEnvironmentProvider, mockPlanner.Object, mockPlanRunner.Object, mockReporter.Object, mockModuleIdentityLifecycleManager.Object, configStore, DeploymentConfigInfo.Empty, serde, encryptionDecryptionProvider, availabilityMetric);

            // Act
            // Assert
            await agent.ReconcileAsync(token);

            mockPlanner.Verify(p => p.PlanAsync(It.IsAny <ModuleSet>(), It.IsAny <ModuleSet>(), It.IsAny <IRuntimeInfo>(), It.IsAny <ImmutableDictionary <string, IModuleIdentity> >()), Times.Never);
            mockReporter.VerifyAll();
            mockPlanRunner.Verify(r => r.ExecuteAsync(1, It.IsAny <Plan>(), token), Times.Never);
        }
예제 #2
0
 public DeploymentStatus(DeploymentStatusCode code, string description)
 {
     this.Code        = code;
     this.Description = description ?? string.Empty;
 }
예제 #3
0
 public DeploymentStatus(DeploymentStatusCode code)
     : this(code, string.Empty)
 {
 }