Exemplo n.º 1
0
        public void AddADoorToBadge_ShouldGetCorrectBool()
        {
            //Arrange
            //That was already done in the Test Initialize

            //ACT
            bool wasAdded = _badgeRepo.AddADoorToBadge(_badge, "B12");

            //Assert
            Assert.IsTrue(wasAdded);
        }
Exemplo n.º 2
0
        public void EditBadge()
        {
            //need to handle if door removed = 0
            Console.Clear();
            Console.WriteLine("2. Edit a Badge \n" +
                              "\t What is the badge number you would like to update? ");
            int   userBadgeNumber = Convert.ToInt32(Console.ReadLine());
            Badge oldBadge        = _badgeRepo.GetBadgeByNumber(userBadgeNumber);

            if (oldBadge.DoorAccess.Count == 0)
            {
                Console.WriteLine("{0} has access to no doors.", oldBadge.Number);
            }
            else if (oldBadge.DoorAccess.Count < 1)
            {
                Console.WriteLine("{0} has access to doors {1}", oldBadge.Number, oldBadge.DisplayDoors(oldBadge.DoorAccess));
            }
            else if (oldBadge.DoorAccess.Count == 1)
            {
                Console.WriteLine("{0} has access to door {1}", Convert.ToString(oldBadge.Number), oldBadge.DisplayDoors(oldBadge.DoorAccess));
            }
            else
            {
                Console.WriteLine("Invalid response. Please enter a valid badge number to update.");
            }
            bool continueToRun = true;

            while (continueToRun)
            {
                Console.WriteLine("What would you like to do? \n" +
                                  "\t 1. Remove a door. \n" +
                                  "\t 2. Add a door. \n" +
                                  "\t 3. Return to main menu.");
                string userInput = Console.ReadLine();
                switch (userInput.ToLower())
                {
                case "1":
                case "remove a door":
                    Console.WriteLine("Which door would you like to remove? ");
                    string userDoorInput = Console.ReadLine();
                    bool   wasRemoved    = _badgeRepo.RemoveADoorFromBadge(oldBadge, userDoorInput);
                    if (wasRemoved == true)
                    {
                        Console.WriteLine("Door was removed.");
                    }
                    else if (wasRemoved == false)
                    {
                        Console.WriteLine("Door was not successfully removed");
                    }
                    else
                    {
                        Console.WriteLine("An error has occured. Return to the main menu to try again.");
                    }

                    if (oldBadge.DoorAccess.Count < 1)
                    {
                        Console.WriteLine("{0} has access to doors {1}", Convert.ToString(oldBadge.Number), oldBadge.DisplayDoors(oldBadge.DoorAccess));
                    }
                    else if (oldBadge.DoorAccess.Count == 1)
                    {
                        Console.WriteLine("{0} has access to door {1}", Convert.ToString(oldBadge.Number), oldBadge.DisplayDoors(oldBadge.DoorAccess));
                    }
                    else
                    {
                        Console.WriteLine("Invalid response. Please enter a valid door number to add.");
                    }
                    break;

                case "2":
                case "add a door":
                    Console.WriteLine("\n Enter in the door number you would like to add: ");
                    string userNewDoorInput = Console.ReadLine();
                    _badgeRepo.AddADoorToBadge(oldBadge, userNewDoorInput);
                    if (oldBadge.DoorAccess.Count > 1)
                    {
                        Console.WriteLine("{0} has access to doors {1}", Convert.ToString(oldBadge.Number), oldBadge.DisplayDoors(oldBadge.DoorAccess));
                    }
                    else if (oldBadge.DoorAccess.Count == 1)
                    {
                        Console.WriteLine("{0} has access to door {1}", Convert.ToString(oldBadge.Number), oldBadge.DisplayDoors(oldBadge.DoorAccess));
                    }
                    else
                    {
                        Console.WriteLine("Invalid response. Please enter a valid door number to add.");
                    }
                    break;

                case "3":
                case "return to main menu":
                    continueToRun = false;
                    break;

                default:
                    Console.WriteLine("Invalid response. Attempt was unsuccessful");
                    break;
                }
            }
            _badgeRepo.AddBadgeToDictionary(oldBadge);
            Console.WriteLine(" \n Press any key to continue...");
            Console.ReadKey();
        }