예제 #1
0
        static void Main(string[] args)
        {
            var generator = new FizzBuzzGenerator(new ConsoleOutputWriter());

            generator.Generate();
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            FizzBuzzGenerator fizzBuzzGenerator = new FizzBuzzGenerator(RulesProvider.GetRules());

            Console.WriteLine(string.Join(Environment.NewLine, fizzBuzzGenerator.Generate(12, 125)));
            Console.Read();
        }
예제 #3
0
 public void Setup()
 {
     var rules = new List<IRule>();
     rules.Add(new FizzRule());
     rules.Add(new BuzzRule());
     _fizzBuzz = new FizzBuzzGenerator(rules);
 }
예제 #4
0
        public void Setup()
        {
            var rules = new List <IRule>();

            rules.Add(new FizzRule());
            rules.Add(new BuzzRule());
            _fizzBuzz = new FizzBuzzGenerator(rules);
        }
예제 #5
0
		public void Can_transform_number_to_string()
		{
			var fb = new FizzBuzzGenerator();

			var result = fb.Transform(1);

			Assert.AreEqual("1", result);
		}
예제 #6
0
		public void Number_that_is_multiply_of_3_and_5_returns_FizzBuzz()
		{
			var fb = new FizzBuzzGenerator();

			var resut = fb.Transform(15);

			Assert.AreEqual("FizzBuzz", resut);
		}
예제 #7
0
        public void Number_Fifteen_Should_Be_FizzBuzz(int Number)
        {
            var task = new FizzBuzzGenerator();

            var expectedWord = "FizzBuzz";

            Assert.Equal(expectedWord, task.WordList()[Number - 1]);
        }
예제 #8
0
		static void Main(string[] args)
		{
			var fb = new FizzBuzzGenerator();
			for ( int i = 1; i < 101; i++ )
			{
				Console.WriteLine(fb.Transform(i));
			}
		}
예제 #9
0
 public void Should_Count_All_Words_In_A_Given_Range()
 {
     FizzBuzzGenerator.PrintableRange(1, 20);
     Assert.AreEqual(FizzBuzzGenerator.FizzWordsCount, 4);
     Assert.AreEqual(FizzBuzzGenerator.BuzzWordsCount, 3);
     Assert.AreEqual(FizzBuzzGenerator.FizzBuzzWordsCount, 1);
     Assert.AreEqual(FizzBuzzGenerator.LuckyWordsCount, 2);
     Assert.AreEqual(FizzBuzzGenerator.NumberCount, 10);
 }
예제 #10
0
        static void Main(string[] args)
        {
            IFizzBuzzGenerator fizzBuzzGenerator = new FizzBuzzGenerator();
            string             fizzBuzzResult;
            string             minRangeValue;
            string             maxRangeValue;

            while (true)
            {
                //Program Description
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\tFIZZ - BUZZ PROGRAM");
                Console.WriteLine();
                Console.WriteLine("For each value in an inclusive range [min, max] prints: ");
                Console.WriteLine("  - \"Fizz\" if the value is divisible by 3");
                Console.WriteLine("  - \"Buzz\" if the value is divisible by 5");
                Console.WriteLine("  - \"FizzBuzz\" if the value is divisible by 3 and by 5");
                Console.WriteLine("  - Otherwise prints the value itself");
                Console.WriteLine();
                Console.WriteLine("* Floating point range values are allowed, but they will be rounded to the nearest even int if ends in .5 * ");
                Console.WriteLine("* An invalid input will tranlate into a value of 0 * ");
                Console.WriteLine();
                Console.WriteLine();

                //Input Data
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Please, enter the range:");
                Console.Write(" Min: ");
                minRangeValue = Console.ReadLine();
                Console.Write(" Max: ");
                maxRangeValue = Console.ReadLine();
                Console.WriteLine();
                Console.WriteLine();

                //Create FizzBuzz Message
                try
                {
                    fizzBuzzResult = fizzBuzzGenerator.GenerateFizzBuzzForRange(minRangeValue, maxRangeValue);
                }
                catch (ArgumentException argumentException)
                {
                    fizzBuzzResult = argumentException.Message;
                }

                //Print the FizzBuzz Message and Continue
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine($"FIZZ - BUZZ RESULT {fizzBuzzGenerator.Range}:");
                Console.WriteLine(fizzBuzzResult);
                Console.WriteLine();
                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("Press any key to reset");
                Console.ReadLine();
                Console.Clear();
            }
        }
예제 #11
0
        static void Main(string[] args)
        {
            var fizzBuzzGenerator = new FizzBuzzGenerator(_console);

            Console.WriteLine("Welcome to FizzBuzz!\n");
            Console.WriteLine("Starting FizzBuzz...\n");
            fizzBuzzGenerator.Start();

            Console.ReadKey();
        }
예제 #12
0
        static void Main(string[] args)
        {
            var fizzBuzzGenerator = new FizzBuzzGenerator(_console);

            Console.WriteLine("Welcome to FizzBuzz!\n");
            Console.WriteLine("Starting FizzBuzz...\n");
            fizzBuzzGenerator.Start();

            Console.ReadKey();
        }
예제 #13
0
 public static void Main(string[] args)
 {
     FizzBuzzGenerator fizzbizz = new FizzBuzzGenerator ();
     InputParser parser = new InputParser ();
     for (int i = 1; i < 100; i++) {
         int value = parser.Parse (i.ToString ());
         Console.Write(fizzbizz.GetToken (value));
         Console.Write (", ");
     }
     Console.Read ();
 }
        public void FizzBuzzGeneratorShouldPrintValues100Times()
        {
            // Arrange
            _console = MockRepository.GenerateMock<IConsole>();
            var generator = new FizzBuzzGenerator(_console);
            _console.Expect(x => x.Print(Arg<string>.Is.Anything)).Repeat.Times(100);

            // Act
            generator.Start();

            // Assert
            _console.VerifyAllExpectations();
        }
        public void FizzBuzzGeneratorShouldPrintFizzForMultiplesOfThree()
        {
            // Arrange
            _console = MockRepository.GenerateMock<IConsole>();
            var generator = new FizzBuzzGenerator(_console);
            _console.Expect(x => x.Print(Arg<string>.Matches(Is.Equal("Fizz")))).Repeat.AtLeastOnce();

            // Act
            generator.Start();

            // Assert
            _console.VerifyAllExpectations();
        }
예제 #16
0
        static void Main(string[] args)
        {
            Console.WriteLine("FizzBuzz Generator Output:");

            int counter = 1;

            foreach (var o in FizzBuzzGenerator.GenerateElement())
            {
                Console.WriteLine("{0,-3}: {1}", counter++, o);
            }

            Console.WriteLine("Press any key to exit...");

            Console.ReadKey();
        }
예제 #17
0
파일: UnitTest1.cs 프로젝트: nchetan/poc
        public void TestMethod1()
        {
            var expected = @"1
            2
            Fizz
            4
            Buzz
            Fizz
            7
            8
            Fizz
            Buzz
            11
            Fizz
            13
            14
            FizzBuzz
            ";

            var serviceUnderTest = new FizzBuzzGenerator();
            var actual = serviceUnderTest.Execute();

            Assert.AreEqual(expected, actual);
        }
예제 #18
0
 public void Should_Count_FizzBuzz_Words()
 {
     FizzBuzzGenerator.PrintableRange(15, 1);
     Assert.AreEqual(FizzBuzzGenerator.FizzBuzzWordsCount, 1);
 }
예제 #19
0
 public void Should_Count_Luck_Words()
 {
     FizzBuzzGenerator.PrintableRange(3, 1);
     Assert.AreEqual(FizzBuzzGenerator.LuckyWordsCount, 1);
 }
예제 #20
0
 public void Should_Count_Numbers()
 {
     FizzBuzzGenerator.PrintableRange(1, 1);
     Assert.AreEqual(FizzBuzzGenerator.NumberCount, 1);
 }
예제 #21
0
 public void Should_Return_Right_Values_To_Print_For_The_Given_Range()
 {
     Assert.AreEqual(
         FizzBuzzGenerator.PrintableRange(1, 20),
         "1 2 lucky 4 buzz fizz 7 8 fizz buzz 11 fizz lucky 14 fizzbuzz 16 17 fizz 19 buzz");
 }
예제 #22
0
        public void Should_Return_FizzBuzz_For_Numbers_Multiplied_By_15()
        {
            string fizzWord = FizzBuzzGenerator.Range(15, 1).Single();

            Assert.AreEqual(fizzWord, "fizzbuzz");
        }
예제 #23
0
        public void Should_Return_Lucky_For_Numbers_That_Contains_3()
        {
            string fizzWord = FizzBuzzGenerator.Range(3, 1).Single();

            Assert.AreEqual(fizzWord, "lucky");
        }
예제 #24
0
 static void Main(string[] args)
 {
     FizzBuzzGenerator fizzBuzzGenerator = new FizzBuzzGenerator(RulesProvider.GetRules());
     Console.WriteLine(string.Join(Environment.NewLine, fizzBuzzGenerator.Generate(12, 125)));
     Console.Read();
 }
예제 #25
0
 static void Main(string[] args)
 {
     FizzBuzzGenerator.GenerateFizzBuzz();
 }
예제 #26
0
 public void SetUp()
 {
     FizzBuzzGenerator fizzBuzzGenerator = new FizzBuzzGenerator();
     enumerator = fizzBuzzGenerator.GetEnumerator();
 }