예제 #1
0
        public Program()
        {
            _loggerFactory = new LoggerFactory();

            var commandProvider = new CommandOutputProvider();
            _loggerFactory.AddProvider(commandProvider);
        }
예제 #2
0
        public void BaseSetup()
        {
            LogOutput = new StringBuilder();

            Log = new LoggerConfiguration()
                  .WriteTo.TextWriter(new StringWriter(LogOutput), outputTemplate: "{Message}{NewLine}{Exception}", formatProvider: new StringFormatter(null))
                  .CreateLogger();

            RootResource rootDocument = Substitute.For <RootResource>();

            rootDocument.ApiVersion = "2.0";
            rootDocument.Version    = "2.0";
            rootDocument.Links.Add("Tenants", "http://tenants.org");

            Repository = Substitute.For <IOctopusAsyncRepository>();
            Repository.Client.RootDocument.Returns(rootDocument);

            ClientFactory = Substitute.For <IOctopusClientFactory>();

            RepositoryFactory = Substitute.For <IOctopusAsyncRepositoryFactory>();
            RepositoryFactory.CreateRepository(null).ReturnsForAnyArgs(Repository);

            FileSystem = Substitute.For <IOctopusFileSystem>();

            CommandOutputProvider = new CommandOutputProvider(Log);

            CommandLineArgs = new List <string>
            {
                "--server=http://the-server",
                "--apiKey=ABCDEF123456789"
            };
        }
예제 #3
0
        public TestLogger(IRuntimeEnvironment runtimeEnv, bool debug = false)
        {
            var commandOutputProvider = new CommandOutputProvider(runtimeEnv);
            if (debug)
            {
                commandOutputProvider.LogLevel = LogLevel.Debug;
            }

            _commandOutputLogger = (CommandOutputLogger)commandOutputProvider.CreateLogger("");
        }
예제 #4
0
        public TestLogger(IRuntimeEnvironment runtimeEnv, bool debug = false)
        {
            var commandOutputProvider = new CommandOutputProvider(runtimeEnv);

            if (debug)
            {
                commandOutputProvider.LogLevel = LogLevel.Debug;
            }

            _commandOutputLogger = (CommandOutputLogger)commandOutputProvider.CreateLogger("");
        }
예제 #5
0
        public TestLogger(bool debug = false)
        {
            var commandOutputProvider = new CommandOutputProvider();

            if (debug)
            {
                commandOutputProvider.LogLevel = LogLevel.Debug;
            }

            _commandOutputLogger = (CommandOutputLogger)commandOutputProvider.CreateLogger("");
        }
        public void BaseSetup()
        {
            LogOutput = new StringBuilder();

            Log = new LoggerConfiguration()
                  .WriteTo.TextWriter(new StringWriter(LogOutput), outputTemplate: "{Message}{NewLine}{Exception}", formatProvider: new StringFormatter(null))
                  .CreateLogger();

            RootResource rootDocument = Substitute.For <RootResource>();

            rootDocument.ApiVersion = "2.0";
            rootDocument.Version    = "2.0";
            rootDocument.Links.Add("Tenants", "http://tenants.org");

            Repository = Substitute.For <IOctopusAsyncRepository>();
            Repository.LoadRootDocument().Returns(rootDocument);
            Repository.HasLink("Spaces").Returns(true);
            Repository.HasLink(Arg.Is <string>(arg => arg != "Spaces")).Returns(async call => (await Repository.LoadRootDocument()).HasLink(call.Arg <string>()));
            Repository.Link(Arg.Any <string>()).Returns(async call => (await Repository.LoadRootDocument()).Link(call.Arg <string>()));

            Repository.Machines.FindByNames(Arg.Any <IEnumerable <string> >(), Arg.Any <string>(), Arg.Any <object>())
            .Returns(new List <MachineResource>());
            Repository.Environments.FindByNames(
                Arg.Is <List <string> >(arg => arg.TrueForAll(arg2 => arg2 == ValidEnvironment)),
                Arg.Any <string>(),
                Arg.Any <object>())
            .Returns(new List <EnvironmentResource>()
            {
                new EnvironmentResource()
                {
                    Name = ValidEnvironment
                }
            });
            Repository.Environments.FindByNames(
                Arg.Is <List <string> >(arg => arg.TrueForAll(arg2 => arg2 != ValidEnvironment)),
                Arg.Any <string>(),
                Arg.Any <object>())
            .Returns(new List <EnvironmentResource>());

            ClientFactory = Substitute.For <IOctopusClientFactory>();

            RepositoryFactory = Substitute.For <IOctopusAsyncRepositoryFactory>();
            RepositoryFactory.CreateRepository(null).ReturnsForAnyArgs(Repository);

            FileSystem = Substitute.For <IOctopusFileSystem>();

            CommandOutputProvider = new CommandOutputProvider(Log);

            CommandLineArgs = new List <string>
            {
                "--server=http://the-server",
                "--apiKey=ABCDEF123456789"
            };
        }