示例#1
0
        [TestCase(1, 1, -10, 0, 0, true)] //Can enter negative pass yards
        public void CanEnterValidStatsTests(decimal passesAttempted, decimal passesCompleted, decimal passingYards, decimal touchdownPasses, decimal interceptions, bool validInput)
        {
            QBRRequest request = new QBRRequest()
            {
                PassesAttempted = passesAttempted,
                PassesCompleted = passesCompleted,
                PassingYards    = passingYards,
                Interceptions   = interceptions,
                TouchdownPasses = touchdownPasses
            };
            QBRResponse response = QBRCalculations.CalculateQBR(request);

            Assert.AreEqual(validInput, response.ValidInput);
        }
示例#2
0
        public void QBRCalculationTest(string name, decimal passesAttempted, decimal passesCompleted, decimal passingYards, decimal touchdownPasses, decimal interceptions, decimal expectedQBR)
        {
            QBRRequest request = new QBRRequest()
            {
                Name            = name,
                PassesAttempted = passesAttempted,
                PassesCompleted = passesCompleted,
                PassingYards    = passingYards,
                Interceptions   = interceptions,
                TouchdownPasses = touchdownPasses
            };
            QBRResponse response = QBRCalculations.CalculateQBR(request);

            Assert.AreEqual(expectedQBR, response.Rating);
        }
 public void Start()
 {
     Greet();
     while (true)
     {
         QBRRequest  request  = TakeInStats();
         QBRResponse response = QBRCalculations.CalculateQBR(request);
         DisplayRating(response);
         bool nextRating = CalculateAnotherRating();
         if (!nextRating)
         {
             break;
         }
         Console.Clear();
     }
     Console.WriteLine("Press any key to quit...");
     Console.ReadKey();
 }
        private QBRRequest TakeInStats()
        {
            QBRRequest    request     = new QBRRequest();
            StringBuilder statsString = new StringBuilder();

            while (true)
            {
                Console.WriteLine("Enter in a quarterback name:");
                request.Name = Console.ReadLine();
                if (request.Name.Length > 0 && request.Name.Length < 40)
                {
                    statsString.AppendLine($"Name: {request.Name}");
                    Console.Clear();
                    Console.WriteLine(statsString.ToString());
                    break;
                }
                else
                {
                    Console.WriteLine("QB name cannot be blank.");
                }
            }
            while (true)
            {
                Console.WriteLine("How many passes attempted?");
                string userInput = Console.ReadLine();
                bool   moveOn    = validatePositiveInput("Pass Attempts", userInput);
                if (moveOn == true)
                {
                    statsString.AppendLine($"Pass Attempts: {userInput}");
                    request.PassesAttempted = Int32.Parse(userInput);
                    Console.Clear();
                    Console.WriteLine(statsString.ToString());
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("How many passes completed?");
                string userInput = Console.ReadLine();
                bool   moveOn    = validatePositiveInput("Pass Completions", userInput);
                if (moveOn == true)
                {
                    statsString.AppendLine($"Pass Completions: {userInput}");
                    request.PassesCompleted = Int32.Parse(userInput);
                    Console.Clear();
                    Console.WriteLine(statsString.ToString());
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("How many passing yards?");
                string userInput = Console.ReadLine();
                int    passYards = 0;
                bool   moveOn    = Int32.TryParse(userInput, out passYards);
                if (moveOn == true)
                {
                    statsString.AppendLine($"Passing Yards: {passYards}");
                    request.PassingYards = passYards;
                    Console.Clear();
                    Console.WriteLine(statsString.ToString());
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("How many touchdown passes?");
                string userInput = Console.ReadLine();
                bool   moveOn    = validatePositiveInput("Touchdown Passes", userInput);
                if (moveOn == true)
                {
                    statsString.AppendLine($"Touchdown Passes: {userInput}");
                    request.TouchdownPasses = Int32.Parse(userInput);
                    Console.Clear();
                    Console.WriteLine(statsString.ToString());
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("How many interceptions?");
                string userInput = Console.ReadLine();
                bool   moveOn    = validatePositiveInput("Interceptions", userInput);
                if (moveOn == true)
                {
                    statsString.AppendLine($"Interceptions: {userInput}");
                    request.Interceptions = Int32.Parse(userInput);
                    Console.Clear();
                    Console.WriteLine(statsString.ToString());
                    break;
                }
            }
            return(request);
        }