public void AddBadge() { Console.Clear(); Header(); Console.WriteLine("=-=-=-=- Add a Badge -=-=-=-="); Console.WriteLine("What is the number on the Badge:"); int badgeNum = Convert.ToInt32(Console.ReadLine()); if (_repo.GetABadgeByID(badgeNum) != null) { Console.WriteLine("Badge already exists. Try Updating badge instead of Adding"); Console.WriteLine("Press any key to return to main menu."); } else { Badge newBadge = new Badge(badgeNum); bool looper = true; List <string> doors = new List <string>(); while (looper) { Console.WriteLine("Enter a door that Badge #" + badgeNum + " needs access to: "); doors.Add(Console.ReadLine()); Console.WriteLine("Any other doors (y/n)?"); string moreDoors = Console.ReadLine(); if (moreDoors.ToLower() == "n") { looper = false; } } newBadge.Doors = doors; string doorResult = string.Join(",", doors); bool wasAdded = _repo.AddBadge(newBadge); if (wasAdded == true) { Console.WriteLine($"Badge #{newBadge.BadgeID} added Successfully with access to Doors: {doorResult}."); } else { Console.WriteLine($"Oops! Something went wrong adding Badge #{newBadge.BadgeID}. Please try again."); } Console.WriteLine("Press any key to return to the main menu."); } Console.ReadKey(); }
public void GetBadgeByID_ShouldReturnCorrectBadge() //Read { //Arrange Badge badge = new Badge(001, new List <string> { "A1", "A2" }); Badge_Repo repo = new Badge_Repo(); repo.AddBadge(badge); int badgeID = 001; //Act Badge searchResult = repo.GetABadgeByID(badgeID); //Assert Assert.AreEqual(searchResult.BadgeID, badgeID); }
public void DeleteBadge_ShouldReturnTrue() //Delete { //Arrange Badge badge = new Badge(001, new List <string> { "A1", "A2" }); Badge_Repo repo = new Badge_Repo(); repo.AddBadge(badge); int badgeID = 001; //Act Badge oldBadge = repo.GetABadgeByID(badgeID); bool removeResult = repo.DeleteBadge(oldBadge); //Assert Assert.IsTrue(removeResult); }