Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please identify the discrepencies in the code in each test scenario. Then correct the code on the TakingTurns.cs . Note: do not edit the TakingTurnsQueue.cs

Please identify the discrepencies in the code in each test scenario. Then correct the code on the TakingTurns.cs. Note: do not edit the TakingTurnsQueue.cs, it will be provided as a reference.
TakingTurns.cs
public static class TakingTurns
{
public static void Test()
{
// TODO Problem 1- Run test cases and fix the code to match requirements
// Test Cases
// Test 1
// Scenario: Create a queue with the following people and turns: Bob (2), Tim (5), Sue (3) and
// run until the queue is empty
// Expected Result: Bob, Tim, Sue, Bob, Tim, Sue, Tim, Sue, Tim, Tim
Console.WriteLine("Test 1");
var players = new TakingTurnsQueue();
players.AddPerson("Bob",2);
players.AddPerson("Tim",5);
players.AddPerson("Sue",3);
Console.WriteLine(players); // This can be un-commented out for debug help
while (players.Length >0)
players.GetNextPerson();
// Defect(s) Found: mishandling of the players. players did not display in expected order.
Console.WriteLine("---------");
// Test 2
// Scenario: Create a queue with the following people and turns: Bob (2), Tim (5), Sue (3)
// After running 5 times, add George with 3 turns. Run until the queue is empty.
// Expected Result: Bob, Tim, Sue, Bob, Tim, Sue, Tim, George, Sue, Tim, George, Tim, George
Console.WriteLine("Test 2");
players = new TakingTurnsQueue();
players.AddPerson("Bob",2);
players.AddPerson("Tim",5);
players.AddPerson("Sue",3);
for (int i =0; i <5; i++)
{
players.GetNextPerson();
// Console.WriteLine(players);
}
players.AddPerson("George",3);
// Console.WriteLine(players);
while (players.Length >0)
players.GetNextPerson();
// Defect(s) Found:
Console.WriteLine("---------");
// Test 3
// Scenario: Create a queue with the following people and turns: Bob (2), Tim (Forever), Sue (3)
// Run 10 times.
// Expected Result: Bob, Tim, Sue, Bob, Tim, Sue, Tim, Sue, Tim, Tim
Console.WriteLine("Test 3");
players = new TakingTurnsQueue();
players.AddPerson("Bob",2);
players.AddPerson("Tim",0);
players.AddPerson("Sue",3);
// Console.WriteLine(players);
for (int i =0; i <10; i++)
{
players.GetNextPerson();
// Console.WriteLine(players);
}
// Defect(s) Found:
Console.WriteLine("---------");
// Test 4
// Scenario: Create a queue with the following people and turns: Tim (Forever), Sue (3)
// Run 10 times.
// Expected Result: Tim, Sue, Tim, Sue, Tim, Sue, Tim, Tim, Tim, Tim
Console.WriteLine("Test 4");
players = new TakingTurnsQueue();
players.AddPerson("Tim",-3);
players.AddPerson("Sue",3);
// Console.WriteLine(players);
for (int i =0; i <10; i++)
{
players.GetNextPerson();
// Console.WriteLine(players);
}
// Defect(s) Found:
Console.WriteLine("---------");
// Test 5
// Scenario: Try to get the next person from an empty queue
// Expected Result: Error message should be displayed
Console.WriteLine("Test 5");
players = new TakingTurnsQueue();
players.GetNextPerson();
// Defect(s) Found:
}
}
TakingTurnsQueue.cs
///

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions