示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the \n 1.The start number \n 2.The final one");

            var inputStartNumber = CheckConvertToDouble(Console.ReadLine());

            var inputLastNumber = CheckConvertToDouble(Console.ReadLine());

            Console.WriteLine("Please enter the prime numbers \n 1. First prime number \n 2. Second prime number ");

            var firstPrime = PrimeNumberValidation(Console.ReadLine());

            var secondPrime = PrimeNumberValidation(Console.ReadLine());

            Console.WriteLine("Please enter the definition for special numbers \n  1. For the first value \n 2. For the second value ");

            string firstDefinition  = Console.ReadLine();
            string secondDefinition = Console.ReadLine();

            Console.WriteLine("______________________________________________________");

            var fizzBuzz = new FizzBuzzModel()
            {
                startNumber      = inputStartNumber,
                lastNumber       = inputLastNumber,
                firstPrime       = firstPrime,
                secondPrime      = secondPrime,
                firstDefinition  = firstDefinition,
                secondDefinition = secondDefinition
            };

            FizzBuzzLib.FizzBuzzLogic(fizzBuzz);

            Console.ReadKey();
        }
示例#2
0
文件: Program.cs 项目: SVaki/FizzBuzz
        /// <summary>
        /// This method requires question number as an argument. Question configuration is defined in the App.Config file
        ///Question1, Question3, Question4, Question5, Question6
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            String question = "";

            if (args.Length > 0)
            {
                question = args[0];
            }


            string[] strValue = ConfigurationManager.AppSettings[question.ToLower()].Split(',');


            FizzBuzzLib objFizBizzLib = new FizzBuzzLib();
            string      strOutput     = "";

            if (question.ToLower() == "Question6".ToLower())
            {
                strOutput = objFizBizzLib.PrintDynamicText(strValue);
            }
            else
            {
                strOutput = objFizBizzLib.PrintText(strValue);
            }

            Console.WriteLine("Output for " + question + " is:\n" + strOutput);

            Console.ReadLine();
        }
示例#3
0
        public void IsPositiveNumber_Minus5asInput_False()
        {
            int input = -5;

            var result = FizzBuzzLib.IsPositiveNumber(input);

            Assert.IsFalse(result);
        }
示例#4
0
        public void NotNullValidation_NullInput_False()
        {
            string input = null;

            var result = FizzBuzzLib.NotNullValidation(input);

            Assert.IsFalse(result);
        }
示例#5
0
        public void NumberValidation_MMMasInput_False()
        {
            string input = "MMM";

            var result = FizzBuzzLib.NumberValidation(input);

            Assert.IsFalse(result);
        }
示例#6
0
        public void NotNullValidation_WhiteSpaceasInput_False()
        {
            string input = " ";

            var result = FizzBuzzLib.NotNullValidation(input);

            Assert.IsFalse(result);
        }
示例#7
0
        public void IsPrimeNumberChecker_WhiteSpaceasPrimeNumber_False()
        {
            string input = " ";

            var result = FizzBuzzLib.IsPrimeNumberChecker(input);

            Assert.IsFalse(result);
        }
示例#8
0
        public void IsPrimeNumberChecker_3asPrimeNumber_True()
        {
            string input = "3";

            var result = FizzBuzzLib.IsPrimeNumberChecker(input);

            Assert.IsTrue(result);
        }
示例#9
0
        public void IsPositiveNumber_5asInput_True()
        {
            int input = 5;

            var result = FizzBuzzLib.IsPositiveNumber(input);

            Assert.IsTrue(result);
        }
示例#10
0
        public void GenerateTest_Abnormal(int val)
        {
            var fb = new FizzBuzzLib();

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                fb.Generate(val);
            });
        }
示例#11
0
        public void ConvertToFizzBuzzTest_Abnromal(int val)
        {
            var fb = new FizzBuzzLib();

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                fb.ConvertToFizzBuzz(val);
            });
        }
示例#12
0
        public void NumberValidation_5asInput_True()
        {
            string input = "5";

            FizzBuzzLib.Value = 5;

            var result = FizzBuzzLib.NumberValidation(input);

            Assert.IsTrue(result);
        }
示例#13
0
        public void ParseToDouble_5asInput_5()
        {
            string input = "5";

            double expected = 5;

            var result = FizzBuzzLib.ParseToDouble(input);

            Assert.AreEqual(expected, actual: result);
        }
示例#14
0
        public static double CheckConvertToDouble(string input)
        {
            while (FizzBuzzLib.NumberValidation(input).Equals(false))
            {
                var message = FizzBuzzLib.Message;
                Console.WriteLine(message);
                input = Console.ReadLine();
            }
            double value = FizzBuzzLib.ParseToDouble(input);

            return(value);
        }
示例#15
0
        public void StartLastNumberChecker_100asStartNumber1asLastNumber_StartNumber1LastNumber100()
        {
            double startNumber = 100;

            double finalNumber = 1;

            double expectedStart = 1;

            double expectedFinal = 100;

            FizzBuzzLib.StartLastNumberChecker(ref startNumber, ref finalNumber);

            Assert.AreEqual(startNumber, expectedStart);
            Assert.AreEqual(finalNumber, expectedFinal);
        }
示例#16
0
        public void Count_ShouldReturn7_WhenInputIs7()
        {
            FizzBuzzLib FizzBuzz = new FizzBuzzLib();

            Assert.AreEqual("7", FizzBuzz.Count(7));
        }
示例#17
0
        public void Count_ShouldReturn2_WhenInputIs2()
        {
            FizzBuzzLib FizzBuzz = new FizzBuzzLib();

            Assert.AreEqual("2", FizzBuzz.Count(2));
        }
示例#18
0
        public void GenerateTest_Normal(int val, string expected)
        {
            var fb = new FizzBuzzLib();

            Assert.Equal(expected, fb.Generate(val));
        }
示例#19
0
        public string FizzBuzzLib_Generate()
        {
            var fb = new FizzBuzzLib();

            return(fb.Generate(Val));
        }
示例#20
0
        public void Count_ShouldReturnFizzBuzz_WhenInputIs30()
        {
            FizzBuzzLib FizzBuzz = new FizzBuzzLib();

            Assert.AreEqual("FizzBuzz", FizzBuzz.Count(30));
        }
示例#21
0
        public void ConvertToFizzBuzzTest_Normal(int val, string expected)
        {
            var fb = new FizzBuzzLib();

            Assert.Equal(expected, fb.ConvertToFizzBuzz(val));
        }
示例#22
0
        public void Count_ShouldReturn1_WhenInputIs1()
        {
            FizzBuzzLib FizzBuzz = new FizzBuzzLib();

            Assert.AreEqual("1", FizzBuzz.Count(1));
        }
示例#23
0
 public void BeforeAll()
 {
     var fizzBuzzLib = new FizzBuzzLib();
 }