private void AddABadge() { Console.Clear(); Badges newBadge = new Badges(); Console.WriteLine("Enter the ID Number for this Badge:"); string badgeIDAsString = Console.ReadLine(); newBadge.BadgeID = int.Parse(badgeIDAsString); Console.WriteLine("Enter the doors you would like this Badge to have access to:"); newBadge.AccessibleDoors = Console.ReadLine(); Console.WriteLine("Any other doors? (y/n)"); string additionalDoor = Console.ReadLine().ToLower(); _badgesRepo.AddABadge(newBadge); while (additionalDoor == "y") { Console.WriteLine("Enter the doors you would like this Badge to have access to:"); newBadge.AccessibleDoors = Console.ReadLine(); Console.WriteLine("Any other doors? (y/n)"); additionalDoor = Console.ReadLine(); } if (additionalDoor == "n") { Console.WriteLine("All doors added"); Console.Clear(); Menu(); } }
public void TestGetBadgeByID() { BadgesRepo badgeRepo = new BadgesRepo(); Badges testBadge = new Badges(1, "C4"); badgeRepo.AddABadge(testBadge); Dictionary <int, Badges> testDict = badgeRepo.GetBadges(); foreach (KeyValuePair <int, Badges> badge in testDict) { if (badge.Key == testBadge.BadgeID) { Assert.IsTrue(testBadge.BadgeID == 1); } } }
public void TestingAddABadge() { BadgesRepo badgeRepo = new BadgesRepo(); Badges testBadge = new Badges(1, "C4"); badgeRepo.AddABadge(testBadge); Dictionary <int, Badges> testDict = badgeRepo.GetBadges(); bool badgeIdIsEqual = false; foreach (KeyValuePair <int, Badges> badge in testDict) { if (badge.Key == 1) { badgeIdIsEqual = true; break; } Assert.IsTrue(badgeIdIsEqual); } }