private void UpdateBadgeDoors() { Console.Clear(); GetAllBadges(); Console.WriteLine("\nWhat badge would you like to update:"); string badgeAsString = Console.ReadLine(); int userInput = int.Parse(badgeAsString); BadgeContent pulledID = _badgeRepo.GetBadgeContentByID(userInput); Console.Clear(); Console.WriteLine($"What would you like to do with {badgeAsString}:\n" + $"1. Add a Door\n" + $"2. Remove a Door"); string menuChoice = Console.ReadLine(); if (menuChoice == "1") { Console.WriteLine("What door would you like to add?"); string userDoor = Console.ReadLine(); pulledID.ListOfDoors.Add(userDoor); } else if (menuChoice == "2") { Console.WriteLine("What door would you like to remove?"); string userRemove = Console.ReadLine(); pulledID.ListOfDoors.Remove(userRemove); } else { Console.WriteLine("Incorrect entry, please enter 1 or 2..."); Console.ReadLine(); } }
public void Arrange() { _repo = new BadgeRepo(); _content = new BadgeContent(new List <string> { "a1", "a2", "a3" }, 1102); }
/*private void DeleteExistingBadge() * { * * }*/ private void DeleteDoorOnBadge(BadgeContent oldInfo) { Console.WriteLine("Please enter a door to remove from the badge."); string input = Console.ReadLine(); oldInfo.ListOfDoors.Remove(input); }
public void UpdateDoorsOnBadge() { BadgeContent newContent = new BadgeContent(new List <string> { "a2", "a4", "a5", "a7" }, 1101); bool updateResult = _repo.UpdateDoorsOnBadge(1101, newContent); Assert.IsTrue(updateResult); }
private void SeedContentList() { BadgeContent existingBadge = new BadgeContent(); List <string> newListB100 = new List <string>(); newListB100.Add("a1"); newListB100.Add("b2"); newListB100.Add("b3"); _testRepo._dictionary.Add(100, newListB100); }
public void DeleteExistingBadge_ShouldNotBeBool() { BadgeContent newBadge = new BadgeContent(new List <string> { "a1", "a3" }, 1103); bool wasDeleted = _repo.DeleteExistingBadge(1103); Assert.IsTrue(wasDeleted); }
public void DefaultValues() { _content = new BadgeContent(1, _list); _badgeRepo = new BadgeRepo(); _doorContent = new DoorContent("Whiskey"); string a = "alpha"; _list.Add(a); _badgeRepo.AddNewBadge(_content); _dict.Add(1, _content); }
public void AddToMenuTest_ShouldBeNotNull() { BadgeContent content = new BadgeContent(); content.BadgeID = 1102; BadgeRepo repo = new BadgeRepo(); repo.AddBadgeToList(content); BadgeContent directory = repo.GetBadgeById(1101); Assert.IsNotNull(directory); }
public void Test_GetDoorByKey() { //Arrange SeedContentList(); List <string> testDoor = new List <string>(); testDoor.Add("doorTest"); BadgeContent addBadgeToDict = new BadgeContent(999, testDoor); //Act List <string> testResult = _testRepo.GetDoorByKey(100); int testResultCount = testResult.Count; //Assert Assert.AreEqual(3, testResultCount); }
public void Test_RemoveDoorByKey() { //Arrange SeedContentList(); List <string> testList = new List <string>(); testList.Add("test"); BadgeContent inputToAdd = new BadgeContent(888, testList); _testRepo._dictionary.Add(888, testList); //Act bool result = _testRepo.RemoveDoorbyKey("test"); //Assert Assert.IsTrue(result); }
private void DefaultBadges() { DoorContent a = new DoorContent("Alpha"); DoorContent e = new DoorContent("Echo"); DoorContent f = new DoorContent("Foxtrot"); DoorContent k = new DoorContent("Kilo"); DoorContent n = new DoorContent("November"); DoorContent w = new DoorContent("Whiskey"); DoorContent z = new DoorContent("Zulu"); _doorRepo.AddDoor(a); _doorRepo.AddDoor(e); _doorRepo.AddDoor(f); _doorRepo.AddDoor(k); _doorRepo.AddDoor(n); _doorRepo.AddDoor(w); _doorRepo.AddDoor(z); List <string> listOfDoors = new List <string>(); List <string> listOfDoorsOne = new List <string>(); List <string> listOfDoorsTwo = new List <string>(); listOfDoors.Add("alpha"); listOfDoors.Add("echo"); listOfDoorsOne.Add("foxtrot"); listOfDoorsOne.Add("kilo"); listOfDoorsTwo.Add("november"); listOfDoorsTwo.Add("whiskey"); listOfDoorsTwo.Add("zulu"); BadgeContent torres = new BadgeContent(39007, listOfDoors); BadgeContent owen = new BadgeContent(38235, listOfDoorsOne); BadgeContent ruudberg = new BadgeContent(31234, listOfDoorsTwo); _badgeRepo.AddNewBadge(torres); _badgeRepo.AddNewBadge(owen); _badgeRepo.AddNewBadge(ruudberg); _dic.Add(39007, listOfDoors); _dic.Add(38235, listOfDoorsOne); _dic.Add(31234, listOfDoorsTwo); }
public void Test_CreateNewBadgeID() { //Arrange SeedContentList(); List <string> testList = new List <string>(); BadgeContent inputToAdd = new BadgeContent(555, testList); string resultContent; testList.Add("Test"); //Act _testRepo.CreateNewBadgeID(inputToAdd); resultContent = _testRepo.GetBadgeByKey(555); //Assert Assert.IsNotNull(555); }
private void AddABadge() { Console.Clear(); List <string> newList = new List <string>(); BadgeContent newBadge = new BadgeContent(); Console.WriteLine("What is the number on the badge:"); newBadge.BadgeID = int.Parse(Console.ReadLine()); Console.WriteLine("List a door that it needs access to:"); string doorInputOne = Console.ReadLine().ToLower(); newList.Add(doorInputOne); newBadge.DoorName = newList; _badgeContentRepo.CreateNewBadgeID(newBadge); bool doorAddLoop = true; while (doorAddLoop) { Console.WriteLine("Any other doors you need to add? (y/n)"); string questionInput = Console.ReadLine().ToLower(); switch (questionInput) { case "y": Console.WriteLine("List a door that it needs access to:"); string doorInputTwo = Console.ReadLine().ToLower(); newBadge.DoorName.Add(doorInputTwo); break; case "n": doorAddLoop = false; break; default: Console.WriteLine("Invalid input .Please input y/n. "); break; } } Menu(); }
public void SeedContent() { BadgeContent existingBadge = new BadgeContent(); List <string> newListB100 = new List <string>(); List <string> newListB200 = new List <string>(); List <string> newListB300 = new List <string>(); newListB100.Add("a1"); newListB100.Add("b2"); newListB100.Add("b3"); newListB200.Add("b2"); newListB200.Add("b3"); newListB300.Add("a1"); newListB300.Add("b3"); _badgeContentRepo._dictionary.Add(100, newListB100); _badgeContentRepo._dictionary.Add(200, newListB200); _badgeContentRepo._dictionary.Add(300, newListB300); }
private void SeedMethod() { BadgeContent badge1 = new BadgeContent(new List <string> { "a1", "a2", "a3", "b4", "b6" }, 1101); BadgeContent badge2 = new BadgeContent(new List <string> { "a2", "a3", "a4" }, 1102); BadgeContent badge3 = new BadgeContent(new List <string> { "b3", "b4", "c3" }, 1103); BadgeContent badge4 = new BadgeContent(new List <string> { "a1", "a2", "b6" }, 1104); _badgeRepo.AddBadgeToList(badge1); _badgeRepo.AddBadgeToList(badge2); _badgeRepo.AddBadgeToList(badge3); _badgeRepo.AddBadgeToList(badge4); }
private void UpdateBadgeDoors() { Console.Clear(); //show list of badges to choose from GetAllBadges(); //return badge number and list of doors accessible Console.WriteLine("\nWhat badge would you like to update:"); string badgeAsString = Console.ReadLine().ToLower(); int userInput = int.Parse(badgeAsString); BadgeContent pulledID = _badgeRepo.GetBadgeContentByID(userInput); //option to add or remove doors Console.Clear(); Console.WriteLine($"What would you like to do with {badgeAsString}:\n" + $"1. Add a Door\n" + $"2. Remove a Door"); string menuChoice = Console.ReadLine().ToLower(); //add door if (menuChoice == "1") { Console.WriteLine("What door would you like to add?"); string userDoor = Console.ReadLine().ToLower(); pulledID.ListOfDoors.Add(userDoor); } //remove door else if (menuChoice == "2") { Console.WriteLine("What door would you like to remove?"); string userRemove = Console.ReadLine().ToLower(); pulledID.ListOfDoors.Remove(userRemove); } else { Console.WriteLine("Incorrect entry, please enter 1 or 2..."); Console.ReadLine(); } }
private void CreateANewBadge() { BadgeContent newBadge = new BadgeContent(); List <string> listOfDoors = new List <string>(); Console.Clear(); Console.WriteLine("Please enter the ID numbers on the badge."); string idAsString = Console.ReadLine(); int badgeId = int.Parse(idAsString); newBadge.BadgeID = badgeId; AnotherDoor: Console.WriteLine("Please enter the door access number."); string doorNum = Console.ReadLine(); listOfDoors.Add(doorNum); Console.WriteLine("Would you like to enter another door: yes/no "); string doorAnswer = Console.ReadLine(); switch (doorAnswer) { case "yes": goto AnotherDoor; case "no": newBadge.ListOfDoors.AddRange(listOfDoors); _badgeRepo.AddBadgeToList(newBadge); break; default: Console.WriteLine("The answer {0} was invalid", doorAnswer); break; } }
public void EditABadge() { Console.Clear(); List <string> newList = new List <string>(); BadgeContent existingBadge = new BadgeContent(); Console.WriteLine("What is the badge number to update?"); string userInputParse = Console.ReadLine(); existingBadge.BadgeID = Int32.Parse(userInputParse); string badgeConfirmed = _badgeContentRepo.GetBadgeByKey(existingBadge.BadgeID); if (badgeConfirmed == null) { Console.WriteLine($"Badge # {userInputParse} does not exist in system."); Console.ReadLine(); Menu(); } int badgeConfirmedInt = Int32.Parse(badgeConfirmed); newList = _badgeContentRepo.GetDoorByKey(badgeConfirmedInt); if (badgeConfirmed != null) { Console.Clear(); Console.WriteLine($"{badgeConfirmed} has access to the following doors :\n" + $"{string.Join(System.Environment.NewLine, newList).ToLower()}"); } else { Console.Clear(); Console.WriteLine("Badge number does not exist"); } Console.ReadLine(); Console.Clear(); Console.WriteLine("What action would you like to do? \n" + "1. Remove a door \n" + "2. Add a door"); string userInputTwo = Console.ReadLine(); switch (userInputTwo) { case "1": Console.Clear(); Console.WriteLine("Which door would you like to remove?"); string doorToRemove = Console.ReadLine().ToLower(); bool removeResult = _badgeContentRepo.RemoveDoorbyKey(doorToRemove); if (removeResult) { Console.WriteLine($"{badgeConfirmed} has access to the following doors :\n" + $"{string.Join(System.Environment.NewLine, newList)}"); Console.ReadLine(); } else { Console.WriteLine($"Badge #{badgeConfirmed} does not have access to Door #{doorToRemove} "); Console.ReadLine(); } break; case "2": Console.Clear(); Console.WriteLine("List a door that it needs access to:"); string doorInputOne = Console.ReadLine().ToLower(); newList.Add(doorInputOne); existingBadge.DoorName = newList; _badgeContentRepo.AddValueToKey(existingBadge.BadgeID, existingBadge.DoorName); Console.WriteLine($"{badgeConfirmed} has access to the following doors :\n" + $"{string.Join(System.Environment.NewLine, newList)}"); Console.ReadLine(); break; default: Console.WriteLine("Please input a valid option"); break; } Menu(); }
public void AddNewBadge_ShouldBeNotNull() { BadgeContent badgeContent = new BadgeContent(1, _list); Assert.IsNotNull(badgeContent); }
private void UpdateExistingBadge() { List <string> listOfDoors = new List <string>(); Console.WriteLine("Here is a list of Badges."); ViewExistingBadges(); //Finding the badge ID Console.WriteLine("Please enter the Badge ID to update."); string badgeAsString = Console.ReadLine(); int badgeID = int.Parse(badgeAsString); BadgeContent newInfo = _badgeRepo.GetBadgeById(badgeID); Console.Clear(); Console.WriteLine("Badge {0} has the following assigned doors", badgeID); ViewListOfDoors(badgeID); Selection: Console.WriteLine("Do you want to add or remove a door? " + "Format* add or remove"); string answer = Console.ReadLine(); if (answer == "add") { Doors: Console.WriteLine("Please enter the door access number."); string doorNum = Console.ReadLine(); listOfDoors.Add(doorNum); Console.WriteLine("Would you like to enter another door: yes/no "); string doorAnswer = Console.ReadLine(); switch (doorAnswer) { case "yes": goto Doors; case "no": newInfo.ListOfDoors.AddRange(listOfDoors); _badgeRepo.UpdateDoorsOnBadge(badgeID, newInfo); break; default: Console.WriteLine("The answer {0} was invalid", doorAnswer); break; } } else if (answer == "remove") { DeleteDoorOnBadge(newInfo); } else { Console.WriteLine("{0} is not a valid input\n" + "please enter valid input", answer); goto Selection; } bool wasUpdated = _badgeRepo.UpdateDoorsOnBadge(badgeID, newInfo); if (wasUpdated) { Console.WriteLine("The badge doors have been updated successfully"); } else { Console.WriteLine("Could not update the badge doors"); } }