I need it to pass the MindTap test in order to receive full credit. I got all my methods to pass except GetLists(), and I am getting a weird error that I am having trouble understanding. This is working fine on my console but it looks MindTap has some different test cases that cause it to fail.
GetLists - "This method continuously prompts for talent codes and displays contestants with the corresponding talent until a sentinel value is entered"
public static void GetLists(int numThisYear, char[] talentCodes, string[] talentCodeStrings, string[] names, char[] talents, int[] counts)
{
char input;
do
{
Write("Enter talent to lookup contestants or press 'q' to quit: ");
input = Char.ToUpper(char.Parse(ReadLine()));
for (int i = 0; i < names.Length; i++)
{
if (input == talents[i])
{
if (!String.IsNullOrEmpty(names[i]))
WriteLine($"{names[i]}");
}
}
} while (input != 'q');
}
Additionally here is the error log from MindTap. Please help.
1) Error : GetListsMethodTest.GetListsTest
System.ArgumentNullException : Value cannot be null.
Parameter name: s
at System.Char.Parse (System.String s) [0x00003] in <7b90a8780ac4414295b539b19eea7eea>:0
at GreenvilleRevenue.GetLists (System.Int32 numThisYear, System.Char[] talentCodes, System.String[] talentCodeStrings, System.String[] names, System.Char[] talents, System.Int32[] counts) [0x0000f] in <4fa6820f6fb84bb29983667e42842788>:0
at GetListsMethodTest.GetListsTest () [0x0004d] in <4fa6820f6fb84bb29983667e42842788>:0
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <7b90a8780ac4414295b539b19eea7eea>:0
And here is the test case
[TestFixture]
public class GetListsMethodTest
{
const int MIN_CONTESTANTS = 0;
const int MAX_CONTESTANTS = 30;
string[] names = new string[MAX_CONTESTANTS];
char[] talents = new char[MAX_CONTESTANTS];
char[] talentCodes = {'S', 'D', 'M', 'O'};
string[] talentCodesStrings = {"Singing", "Dancing", "Musical instrument", "Other"};
int[] counts = {0, 0, 0, 0};
[Test]
public void GetListsTest()
{
string consoleInput = "S\nZ";
using (var inputs = new StringReader(consoleInput))
{
using (StringWriter sw = new StringWriter())
{
Console.SetIn(inputs);
Console.SetOut(sw);
names[0] = "Joe";
names[1] = "Ann";
talents[0] = 'S';
talents[1] = 'M';
GreenvilleRevenue.GetLists(5, talentCodes, talentCodesStrings, names, talents, counts);
StringAssert.Contains("Joe", sw.ToString());
Assert.IsFalse(sw.ToString().Contains("Ann"), "Ann should not be listed in output for singers");
}
}
consoleInput = "M\nZ";
using (var inputs = new StringReader(consoleInput))
{
using (StringWriter sw = new StringWriter())
{
Console.SetIn(inputs);
Console.SetOut(sw);
names[0] = "Joe";
names[1] = "Ann";
talents[0] = 'S';
talents[1] = 'M';
GreenvilleRevenue.GetLists(5, talentCodes, talentCodesStrings, names, talents, counts);
StringAssert.Contains("Ann", sw.ToString());
Assert.IsFalse(sw.ToString().Contains("Joe"), "Joe should not be listed in output for musicians");
}
}
}
}