Exemplo n.º 1
0
        public void Execute_UsesCorrectCommandLineInvocation_ForValidTargetDiscoveryCommands(string discoveryCommand)
        {
            // Arrange
            var instructions      = BuildInstructions(discoveryCommand);
            var variables         = BuildVariables();
            var options           = BuildOptions();
            var commandLineRunner = Substitute.For <ICommandLineRunner>();
            var sut = new NodeExecutor(options, variables, commandLineRunner, new InMemoryLog());
            CommandLineInvocation capturedInvocation = null;
            var fakeResult = new CommandResult("fakeCommand", 0);

            commandLineRunner.Execute(Arg.Do <CommandLineInvocation>(arg => capturedInvocation = arg)).Returns(fakeResult);

            // Act
            sut.Execute(instructions);

            // Assert
            var arguments = capturedInvocation.Arguments.Split(' ');

            arguments.Should().HaveCount(7)
            .And.HaveElementAt(0, $"\"{Path.Combine("expectedBootstrapperPath","bootstrapper.js")}\"")
            .And.HaveElementAt(1, $"\"{discoveryCommand}\"")
            .And.HaveElementAt(2, "\"expectedTargetPath\"")
            .And.HaveElementAt(4, "\"encryptionPassword\"")
            .And.HaveElementAt(5, "\"Octopuss\"")
            .And.HaveElementAt(6, "\"discoveryContextKey\"");
        }
Exemplo n.º 2
0
        public void Execute_ThrowsCommandException_ForUnknownBootstrapperInvocationCommand()
        {
            // Arrange
            var instructions      = BuildInstructions("wrongCommand");
            var variables         = BuildVariables();
            var options           = BuildOptions();
            var commandLineRunner = Substitute.For <ICommandLineRunner>();
            var sut = new NodeExecutor(options, variables, commandLineRunner, new InMemoryLog());

            // Act
            Action action = () => sut.Execute(instructions);

            // Assert
            action.Should().Throw <CommandException>().WithMessage("Unknown bootstrapper invocation command: 'wrongCommand'");
        }