public void DoesListContainID_ShouldReturnFalse() { BadgesRepo repo = new BadgesRepo(); Badge badge = new Badge(); bool doesContain = repo.DoesListContainBadgeID(badge); Assert.IsFalse(doesContain); }
public void DoesListContainID_ShouldReturnTrue() { BadgesRepo repo = new BadgesRepo(); Badge badge = new Badge(); repo.AddBadgeToCollection(badge); bool doesContain = repo.DoesListContainBadgeID(badge); Assert.IsTrue(doesContain); }
public void AddBadge() { Console.Clear(); Badge newBadge = new Badge(); List <string> access = new List <string>(); Console.Write("Enter a badge number: "); string possibleID = Console.ReadLine(); // Checking to make sure that user input is a valid ID option (an integer) // Declaring an initializing 'int newBadgeID' if 'possibleID' is valid if (Int32.TryParse(possibleID, out int newBadgeID)) { newBadge.BadgeID = Convert.ToInt32(possibleID); // Checks to make sure Badge ID isn't already being used if (accessLog.DoesListContainBadgeID(newBadge) == true) { Console.WriteLine("\n" + "Badge ID already being used, choose another Badge ID.\n" + "Press any key to continue..."); Console.ReadKey(); AddBadge(); } else { newBadge.BadgeID = newBadgeID; } } else { Console.WriteLine("\n" + "Enter a proper Badge ID.\n" + "Press any key to continue..."); Console.ReadKey(); AddBadge(); } Console.Write($"What door does it have access to: "); string doorAccess = Console.ReadLine().ToUpper(); // // user is able to input in multiple of the same door access // if (possibleDoors.Contains(doorAccess)) { access.Add(doorAccess); } else { Console.WriteLine("Assignment of unrecognized door access, could not complete request.\n" + "Press any key to continue..."); Console.ReadKey(); MainMenu(); } Console.Write("Any other doors (y/n)?: "); string userInput = Console.ReadLine(); if (userInput == "y" || userInput == "Y") { while (userInput == "y" || userInput == "Y") { Console.Write("Enter door access: "); doorAccess = Console.ReadLine().ToUpper(); if (possibleDoors.Contains(doorAccess)) { access.Add(doorAccess); } else { Console.WriteLine("Assignment of unrecognized door access, could not complete request."); } Console.Write("Any other doors (y/n)?: "); userInput = Console.ReadLine(); } newBadge.Access = access; accessLog.AddBadgeToCollection(newBadge); Console.WriteLine("\n" + "New badge created.\n" + "Press any key to continue..."); Console.ReadKey(); MainMenu(); } else if (userInput == "n" || userInput == "N") { newBadge.Access = access; accessLog.AddBadgeToCollection(newBadge); Console.WriteLine("\n" + "New badge created.\n" + "Press any key to continue..."); Console.ReadKey(); MainMenu(); } else { Console.WriteLine("Did not recognze value, input 'y' or 'n' when prompted, unable to complete request.\n" + "Press any key to continue..."); Console.ReadKey(); AddBadge(); } }