public void Arrange()
 {
     _repo  = new BadgeRepostiory();
     _badge = new Badge(12345, new List <string>()
     {
         "A5", "A7"
     });
     _repo.AddBadgeToDictionary(_badge);
 }
Exemplo n.º 2
0
        // Create new Badge
        private void AddABadge()
        {
            Console.Clear();
            Badge         newBadge = new Badge();
            List <string> Doors    = new List <string>();

            // BadgeID
            Console.WriteLine("What is the number on the badge?");
            string badgeNumber = Console.ReadLine();

            newBadge.BadgeID = int.Parse(badgeNumber);

            Console.WriteLine("List a door that it needs access to:");
            string door = Console.ReadLine();

            Doors.Add(door);

            bool keepRunning = true;

            while (keepRunning)
            {
                Console.WriteLine("Any other doors (y/n).  Type y for yes or n for no.");
                string input = Console.ReadLine().ToLower();
                switch (input)
                {
                case "y":
                    // Add another door
                    Console.WriteLine("List a door that it needs access to:");
                    string door2 = Console.ReadLine();
                    Doors.Add(door2);
                    break;

                case "n":
                    keepRunning = false;
                    break;
                }
            }

            newBadge.Doors = Doors;
            _badgeRepo.AddBadgeToDictionary(newBadge);
        }
        public void AddToDictionary_ShouldGetNotNull()
        {
            // Arrange--> Setting up the playing field
            Badge badge = new Badge();

            badge.BadgeID = 12345;
            BadgeRepostiory repository = new BadgeRepostiory();

            // Act--> Get/run the code we want to test
            repository.AddBadgeToDictionary(_badge);
            KeyValuePair <int, List <string> > badgeKey = repository.GetBadgeByBadgeID(12345);

            // Assert--> Use the assert class to verify the expected outcome
            Assert.IsNotNull(badgeKey.Key);
            Assert.IsNotNull(badgeKey.Value);
        }