Example #1
0
        public void AddNewBadge()
        {
            SortedDictionary <int, List <string> > badgesNumber = _badgesRepo.GetAllBadges();

            Console.Write("What is the number on the badge:  ");
            int number = Convert.ToInt32(Console.ReadLine());

            try
            {
                if (badgesNumber.ContainsKey(number))
                {
                    Console.Clear();
                    Console.WriteLine($"\n\nThe badge number {number} is already exist");
                    Console.ReadKey();
                }
                else
                {
                    bool run = true;

                    Console.WriteLine("List a door that it needs to access to:  ");
                    string doorAccess = Console.ReadLine().ToUpper();
                    Badge  badge      = new Badge(number);
                    badge.DoorName.Add(doorAccess); // Save door access name

                    while (run)
                    {
                        Console.WriteLine("\n\nAny other doors need to access(y/n)?  ");
                        string answer = Console.ReadLine().ToLower();

                        switch (answer)
                        {
                        case "y":
                            Console.WriteLine("Which door would like to add?");
                            string addtionalDoor = Console.ReadLine().ToUpper();
                            badge.DoorName.Add(addtionalDoor);     // Save additional door access name
                            break;

                        case "n":


                            _badgesRepo.AddBadge(badge);     // Save all of them
                            run = false;
                            break;

                        default:
                            Console.WriteLine("Please enter a valid key");
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Please enter a valid key which a number");
                Console.ReadKey();
            }
        }
Example #2
0
        public void GetAllBadges_ShouldReturnNotNull()
        {
            var repo  = new BadgesRepo();
            var badge = new Badge(1, new List <string>());

            repo.AddBadgeToCollection(badge);
            Dictionary <int, Badge> getBadges = repo.GetAllBadges();

            Assert.IsNotNull(getBadges);
        }
Example #3
0
        //View or show
        public void ShowListWithBadges()
        {
            //Arange
            BadgesRepo badgesRepo = new BadgesRepo();

            //Act
            Dictionary <int, Badge> listFromRepo = badgesRepo.GetAllBadges();

            //Assert
            Assert.IsNotNull(badgesRepo);
        }
Example #4
0
        public void AddBadge_AreEqual()
        {
            // Arrange
            Badge      badge     = new Badge(1);
            BadgesRepo badgeRepo = new BadgesRepo();
            SortedDictionary <int, List <string> > _dictionaryBadge = new SortedDictionary <int, List <string> >();

            // Act
            badgeRepo.AddBadge(badge);
            int number = badgeRepo.GetAllBadges().Count;

            // Assert
            Assert.AreEqual(1, number);
        }
Example #5
0
        // list
        private void ViewAllDoors()
        {
            Console.Clear();
            Dictionary <int, Badge> listOfBadges = badgesRepo.GetAllBadges();

            foreach (KeyValuePair <int, Badge> value in listOfBadges)
            {
                Console.WriteLine($"BadgeID: {value.Key}");
                foreach (string doors in value.Value.DoorName)
                {
                    Console.WriteLine($"DoorName: {doors}");
                }
            }
        }
Example #6
0
        private void DisplayAllBadges()
        {
            Console.Clear();
            Console.WriteLine("LIST OF ALL BADGES \n" +
                              "\n");
            Dictionary <int, Badges> displayAllBadges = _badgesRepo.GetAllBadges();

            foreach (var individualBadge in displayAllBadges)
            {
                Console.WriteLine("Key \n" +
                                  $"Badge # {individualBadge.Value.BadgeID}");
                ShowDoors(individualBadge.Value);
            }
            Console.WriteLine("Press any key to continue......");
            Console.ReadKey();
        }
Example #7
0
        public void DisplayAllBadges()
        {
            Console.Clear();

            Dictionary <int, Badge> badges = new Dictionary <int, Badge>();

            badges = accessLog.GetAllBadges();
            foreach (KeyValuePair <int, Badge> badge in badges)
            {
                Console.WriteLine($"Badge ID: {badge.Value.BadgeID}\n" +
                                  $"Door access: {String.Join(",", badge.Value.Access)}\n" +
                                  $"");
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            MainMenu();
        }
Example #8
0
        public void TestForAddingBadge()
        {
            Badge      badge       = new Badge();
            BadgesRepo badgesToAdd = new BadgesRepo();

            //Act
            badgesToAdd.AddBadge(badge);

            //Assert
            Dictionary <int, Badge> badgeDict = badgesToAdd.GetAllBadges();
            bool idIsEqual = false;

            foreach (KeyValuePair <int, Badge> badgedict in badgeDict)
            {
                if (badgedict.Key == badge.BadgeID)
                {
                    idIsEqual = true;
                    break;
                }
            }
        }
Example #9
0
        public void GetAllBadges_ShouldReturnTrue()
        {
            // Arrange
            BadgesRepo badgesRepo = new BadgesRepo();
            SortedDictionary <int, List <string> > _dictionaryBadge = new SortedDictionary <int, List <string> >();

            _dictionaryBadge = badgesRepo.GetAllBadges();
            Badge badge = new Badge(1);

            // Act
            int  numberOfObjectsInDictionary = _dictionaryBadge.Count;
            bool result = false;

            _dictionaryBadge.Add(1, badge.DoorName);

            if (_dictionaryBadge.Count == 1)
            {
                result = true;
            }

            // Assert

            Assert.IsTrue(result);
        }