Ejemplo n.º 1
0
        public void TestEvaulationForFizzBuzzForSamples(int testValue, string shouldBeValue)
        {
            var    actor  = new FizzBuzzActor();
            string result = actor.Evaluate(testValue).GetAwaiter().GetResult();

            result.Should().Be(shouldBeValue);
        }
Ejemplo n.º 2
0
        public void TestLargeRangeWithCalculatedValues()
        {
            Func <int, string> caluclateValue = x =>
            {
                if (x == 0)
                {
                    return(x.ToString());
                }
                else if (x % 3 == 0 && x % 5 == 0)
                {
                    return("FizzBuzz");
                }
                else if (x % 3 == 0)
                {
                    return("Fizz");
                }
                else if (x % 5 == 0)
                {
                    return("Buzz");
                }

                return(x.ToString());
            };

            var actor = new FizzBuzzActor();

            Enumerable.Range(0, 100)
            .Select(x => new { testValue = x, shouldBeValue = caluclateValue(x), resultValue = actor.Evaluate(x).GetAwaiter().GetResult() })
            .All(x => x.resultValue == x.shouldBeValue)
            .Should().BeTrue();
        }