예제 #1
0
        public static async Task Main(string[] args)
        {
            var httpClient  = new HttpClient();
            var httpClient2 = new HttpClient();

            var clientDiceRoll = new DiceRoll(httpClient, TimeSpan.FromSeconds(1));

            var dice = await clientDiceRoll.GetDiceRolled();

            if (dice != null)
            {
                var diceCount = FormattingHelper.FormatDiceCount(dice);

                foreach (var line in diceCount)
                {
                    Console.WriteLine(line);
                }

                string ordered = FormattingHelper.FormatDiceOrdered(dice);

                Console.Error.WriteLine(ordered);

                var json = FormattingHelper.FormatToJsonOrdered(dice);

                var clientRequestBin = new RequestBin(httpClient2, TimeSpan.FromSeconds(1));

                if (!await clientRequestBin.Post(json))
                {
                    Console.Error.WriteLine("Post to request bin service failed");
                }
            }
        }
예제 #2
0
        public void FormatDiceToJsonOrdered()
        {
            var result = FormattingHelper.FormatToJsonOrdered(_dice);

            Assert.Equal("{ \"dice\": [ 1,1,2,2,3,4,5,5,6,6 ] }", result);
        }