Пример #1
0
        public async Task ClientTest([ValueSource("_files")] string file)
        {
            var response = ReadFile(file);
            var client   = new HackerNewsClient(GetFakeHttpClientFactory(response));

            using (ApprovalResults.ForScenario(file))
            {
                var output = await client.GetFrontpage();

                Approvals.Verify(output.Json);
            }
        }
Пример #2
0
        public HackerNewsCommand(string name, HackerNewsClient client) : base(name)
        {
            Description = "Description of TwitterCommand";

            AddOption(new Option(
                          new[] { "--json" },
                          "Return as Json")
            {
                Argument = new Argument <bool>() // defaultValue: () => 99
                {
                    //Arity = ArgumentArity.ExactlyOne
                },
                Description = "Argument description"
            });

            Handler = CommandHandler.Create <bool, bool>(async(json, debug) =>
            {
                var output = await client.GetFrontpage(debug);
                var text   = json ? output.Json : output.String;
                ConsoleHelper.WriteLine(text);
                Environment.ExitCode = (int)ExitCode.Success;
            });
        }