Esempio n. 1
0
        public async Task ValidConnection_RunAsync_CallsInnerCommandRunAsync()
        {
            var cluster           = new Mock <IClusterClient>();
            var healthChunkResult = Task.FromResult(new ClusterHealthChunk(HealthState.Ok));

            cluster.Setup(c => c.GetClusterHealthChunkAsync(60, CancellationToken.None)).Returns(healthChunkResult);
            FabricClient.Setup(c => c.Cluster).Returns(cluster.Object);

            await _command.RunAsync();

            InnerCommand.Verify(c => c.RunAsync(), Times.Once);
        }
        public async Task UnhealthyCluster_RunAsync_NeverInnerCommandRunAsync()
        {
            var cluster           = new Mock <IClusterClient>();
            var healthChunkResult = Task.FromResult(new ClusterHealthChunk(HealthState.Warning));

            cluster.Setup(c => c.GetClusterHealthChunkAsync(60, CancellationToken.None)).Returns(healthChunkResult);
            FabricClient.Setup(c => c.Cluster).Returns(cluster.Object);

            await _command.RunAsync();

            InnerCommand.Verify(c => c.RunAsync(), Times.Never);
        }
Esempio n. 3
0
        public async Task ConnectionCheckException_RunAsync_NeverInnerCommandRunAsync()
        {
            var cluster = new Mock <IClusterClient>();

            cluster
            .Setup(c => c.GetClusterHealthChunkAsync(60, CancellationToken.None))
            .Throws(new Exception("Connection failed."));
            FabricClient.Setup(c => c.Cluster).Returns(cluster.Object);

            await _command.RunAsync();

            InnerCommand.Verify(c => c.RunAsync(), Times.Never);
        }
        public async Task NoHealthCheckRequired_RunAsync_CallsInnerCommandRunAsync()
        {
            _context.Manifest.Options.CheckClusterHealthWaitTime = null;
            var cluster           = new Mock <IClusterClient>();
            var healthChunkResult = Task.FromResult(new ClusterHealthChunk(HealthState.Ok));

            cluster.Setup(c => c.GetClusterHealthChunkAsync(60, CancellationToken.None)).Returns(healthChunkResult);
            FabricClient.Setup(c => c.Cluster).Returns(cluster.Object);

            await _command.RunAsync();

            InnerCommand.Verify(c => c.RunAsync(), Times.Once);
        }
Esempio n. 5
0
        public async Task NoErrors_RunAsync_CallsInnerCommandRunAsync()
        {
            using var outputDir = new TempOutputDir();
            var manifest = TestManifestBuilder
                           .From("http://localhost:19080")
                           .WithTempDir(outputDir.TempDir)
                           .WithGroup(new DeploymentItem
            {
                PackagePath = Path.Combine(TestInfo.OutputDir, "Support", "Packages", "App1")
            })
                           .Build();
            var command = new CopyPackagesLocallyCommand(
                new CommandContext {
                Manifest = manifest, Logger = Logger.Object
            }, InnerCommand.Object);

            await command.RunAsync();

            InnerCommand.Verify(c => c.RunAsync(), Times.Once);
        }