Exemplo n.º 1
0
        public async Task TempPathShouldBeSetWhenDefined()
        {
            string tempPath;
            string?oldTemp = default;

            Directory.CreateDirectory(@"C:\temp");

            try
            {
                oldTemp = Path.GetTempPath();
                string[] args = { $"-{TempKey}=C:\\temp\\" };

                CancellationToken cancellationToken = default;

                using DeployerApp.DeployerApp deployerApp = await
                                                            AppBuilder.BuildAppAsync(args, null, cancellationToken);

                tempPath = Path.GetTempPath();
            }
            finally
            {
                Environment.SetEnvironmentVariable("temp", oldTemp);
            }

            Assert.Equal("C:\\temp\\", tempPath);
        }
Exemplo n.º 2
0
        public async Task LogLevelShouldBeSetWhenArgIsUsed()
        {
            string[] args = { $"{ConfigurationKeys.LogLevel}=error" };

            CancellationToken cancellationToken = default;

            LoggingLevelSwitch level;

            using (DeployerApp.DeployerApp deployerApp = await
                                                         AppBuilder.BuildAppAsync(args, null, cancellationToken))
            {
                level = deployerApp.LevelSwitch;
            }

            Assert.NotEqual(LogEventLevel.Error, level.MinimumLevel);
        }
Exemplo n.º 3
0
        public async Task ExitCodeShouldBeNonZeroForInvalidArgs()
        {
            string[] args = { "--arg1", "--arg2", "asd", "123" };

            CancellationToken cancellationToken = default;
            ILogger           logger            = Logger.None;

            int exitCode;

            using (DeployerApp.DeployerApp deployerApp = await
                                                         AppBuilder.BuildAppAsync(args, logger, cancellationToken))
            {
                exitCode = await deployerApp.ExecuteAsync(args, cancellationToken);
            }

            Assert.NotEqual(0, exitCode);
        }