public void AddDoorToBadge_ShouldGetNotNull() { // Arrange --> Setting up the playing field Badge content = new Badge(); content.DoorNames.Add("A7"); BadgeRepo repository = new BadgeRepo(); // Act --> Get/Run the we want to test repository.AddDoorToBadge(_content.BadgeID, "A7"); Badge doorFromBadge = repository.GetBadgeByKeyValue(12345); // Assert --> Use the assert class to verify the expected outcome Assert.IsNotNull(doorFromBadge); }
public void UpdateExistingBadge() { DisplayAllBadges(); Console.WriteLine("\nEnter the Badge Id you would like to update:\n"); string idAsString = Console.ReadLine(); int idAsInt = int.Parse(idAsString); Badge user = _badges.GetBadgeByKeyValue(idAsInt); Console.WriteLine($"\n{user.BadgeID} has access to doors {user.DoorNames}."); Console.WriteLine("What would you like to do?\n\n" + "1. Remove a door\n" + "2. Add a door\n"); string input = Console.ReadLine(); if (input == "1") { Console.WriteLine("Enter the door you would like to remove:\n"); string doorAsString = Console.ReadLine(); _badges.RemoveDoorFromBadge(idAsInt, doorAsString); // Tried executing verification below, but it crashed the program /*bool wasDeleted = _badges.RemoveDoorFromBadge(idAsInt, doorAsString); * if (wasDeleted) * { * Console.WriteLine("\nDoor removed.\n"); * } * else * { * Console.WriteLine("\nDoor could not be removed."); * }*/ } else if (input == "2") { Console.WriteLine("List a door this badge will have access to:\n"); string doorAsString = Console.ReadLine(); _badges.AddDoorToBadge(idAsInt, doorAsString); } else { Console.WriteLine("Please enter a valid number.\n"); } //Console.WriteLine($"\n{user.BadgeID} has access to doors {user.DoorNames}."); }