コード例 #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 FormatDiceCount()
        {
            var result = FormattingHelper.FormatDiceCount(_dice).ToArray();

            var expected = new string[] {
                "1 -> 2",
                "2 -> 2",
                "3 -> 1",
                "4 -> 1",
                "5 -> 2",
                "6 -> 2"
            };

            Assert.True(expected.All(shouldItem => result.Any(isItem => isItem == shouldItem)));
        }