Beispiel #1
0
        private void EditABadge()
        {
            List <string> doorList = new List <string>();

            Console.WriteLine("What is the badge number to update?");
            int badgeID = int.Parse(Console.ReadLine());

            Console.WriteLine($"{badgeID} has access to doors:");
            foreach (string doorAccess in _badgeRepo.GetAllBadges()[badgeID])
            {
                Console.WriteLine(doorAccess);
            }
            Console.WriteLine("What would you like to do?\n" +
                              "1. Remove a door.\n" +
                              "2. Add a door.");
            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                Console.WriteLine("Which door would you like to remove?");
                string doorInput = Console.ReadLine();
                foreach (var doorA in _badgeRepo.GetAllBadges()[badgeID])
                {
                    if (doorInput == doorA)
                    {
                        _doorList.Remove(doorA);
                        break;
                    }
                }
                //remove door
                break;

            case "2":
                Console.WriteLine("What door will you be adding to this ID?");
                _doorList.Add(Console.ReadLine());
                //add door
                break;

            default:
                break;
            }
        }
        public void AddToDictionaryTest()
        {
            List <string> door1 = new List <string>();

            door1.Add("AD4");
            KomodoInsuranceDictRepository    repoInfo       = new KomodoInsuranceDictRepository();
            KomodoInsurancePOCO              accessInfo     = new KomodoInsurancePOCO(1, door1);
            KomodoInsurancePOCO              accessInfo2    = new KomodoInsurancePOCO(2, door1);
            KomodoInsurancePOCO              accessInfo3    = new KomodoInsurancePOCO(3, door1);
            Dictionary <int, List <string> > employeeBadges = repoInfo.GetAllBadges();

            repoInfo.AddToDictionary(accessInfo);
            repoInfo.AddToDictionary(accessInfo2);
            repoInfo.AddToDictionary(accessInfo3);

            var expected = 3;
            var actual   = employeeBadges.Keys.Count;

            Assert.AreEqual(expected, actual);
        }
        public void ReplaceInDictionary()
        {
            List <string> door1 = new List <string>();

            door1.Add("AD4");
            List <string> door2 = new List <string>();

            door2.Add("D34");
            KomodoInsuranceDictRepository repoInfo    = new KomodoInsuranceDictRepository();
            KomodoInsurancePOCO           accessInfo  = new KomodoInsurancePOCO(1, door1);
            KomodoInsurancePOCO           accessInfo2 = new KomodoInsurancePOCO(2, door1);
            KomodoInsurancePOCO           accessInfo3 = new KomodoInsurancePOCO(3, door1);

            repoInfo.AddToDictionary(accessInfo);
            repoInfo.AddToDictionary(accessInfo2);
            repoInfo.AddToDictionary(accessInfo3);

            repoInfo.ChangeDoors(accessInfo2.BadgeID, door2);

            var expected = door2;
            var actual   = repoInfo.GetAllBadges()[2];

            Assert.AreEqual(expected, actual);
        }