Exemple #1
0
        private async Task Run()
        {
            if (_args?.Length != 1 || !new[] { "ok", "fail" }.Any(p =>
                                                                  p.Equals(_args?.First(), StringComparison.InvariantCultureIgnoreCase)))
            {
                await Console.Error.WriteLineAsync(
                    "You must enter a single parameter:\n  OK - Runs successfully\n  FAIL - Executes with failure");
            }

            var selectedOption = _args?.First();

            if (selectedOption != null &&
                selectedOption.Equals("ok", StringComparison.InvariantCultureIgnoreCase))
            {
                await Console.Out.WriteLineAsync(OkDependency.GetMessage());

                return;
            }

            if (selectedOption != null &&
                selectedOption.Equals("fail", StringComparison.InvariantCultureIgnoreCase))
            {
                await Console.Out.WriteLineAsync(FailDependency.GetMessage());

                return;
            }

            await Console.Error.WriteLineAsync("Unidentified error!");
        }
Exemple #2
0
 public Program(OkDependency okDependency, FailDependency failDependency)
 {
     OkDependency   = okDependency;
     FailDependency = failDependency;
 }