예제 #1
0
        public void Test_list_having_longest_streak_in_the_middle()
        {
            var flips = new List <CoinFlipResult>()
            {
                CoinFlipResult.Head,
                CoinFlipResult.Head,
                CoinFlipResult.Head,
                CoinFlipResult.Tail,
                CoinFlipResult.Tail,
                CoinFlipResult.Tail,
                CoinFlipResult.Tail,
                CoinFlipResult.Head,
                CoinFlipResult.Head,
                CoinFlipResult.Head,
                CoinFlipResult.Head,
                CoinFlipResult.Head,
                CoinFlipResult.Tail,
                CoinFlipResult.Head,
                CoinFlipResult.Head,
            };

            var n = new CoinFlipAnalyzer().CountLongestStreak(flips);

            Assert.AreEqual(n, 5);
        }
예제 #2
0
        public void Test_empty_list()
        {
            var flips = new List <CoinFlipResult>()
            {
            };
            var n = new CoinFlipAnalyzer().CountLongestStreak(flips);

            Assert.AreEqual(n, 0);
        }
예제 #3
0
        public void Test_list_with_two_of_different_kind()
        {
            var flips = new List <CoinFlipResult>()
            {
                CoinFlipResult.Head
            };
            var n = new CoinFlipAnalyzer().CountLongestStreak(flips);

            Assert.AreEqual(n, 1);
        }
예제 #4
0
        public void Test_single_item_list()
        {
            var flips = new List <CoinFlipResult>()
            {
                CoinFlipResult.Head
            };
            var n = new CoinFlipAnalyzer().CountLongestStreak(flips);

            Assert.AreEqual(n, 1);
        }
예제 #5
0
        static void Main(string[] args)
        {
            var coinFlipper      = new CoinFlipper.CoinFlipper();
            var coinFlipAnalyzer = new CoinFlipAnalyzer();

            Console.WriteLine(coinFlipper.Flip());

            var flips = coinFlipper.FlipLikeCrazy(5).ToList();

            Console.WriteLine("Flipped like crazy {0} times. Got {1} heads and {2} tails. " +
                              "With a longest streak of {3} flip restuls of the same kind in a row!!!",
                              flips.Count(),
                              flips.Count(f => f == CoinFlipResult.Head),
                              flips.Count(f => f == CoinFlipResult.Tail),
                              coinFlipAnalyzer.CountLongestStreak(flips)
                              );

            Console.ReadKey();
        }