public void AddABadge() { List <string> doorsToAccess = new List <string>(); int idToAdd = 0; bool numberNeed = true; while (numberNeed) { Console.Clear(); Console.WriteLine("What is the number on the badge: "); string userID = Console.ReadLine(); int id; Int32.TryParse(userID, out id); //Console.WriteLine(id); if (id != 0) { idToAdd = id; numberNeed = false; } else { Console.WriteLine("Please enter a number"); } } bool moreDoor = true; while (moreDoor) { Console.WriteLine("\nWrite a door that it needs access to: "); doorsToAccess.Add(Console.ReadLine()); bool moreQuestion = true; while (moreQuestion) { Console.WriteLine("\nAny other dooors? (y/n)"); string moreInput = Console.ReadLine(); switch (moreInput) { case "y": moreQuestion = false; break; case "n": moreDoor = false; moreQuestion = false; break; default: Console.WriteLine("Please type y or n"); break; } } } Badge newBadge = new Badge(idToAdd, doorsToAccess); _ = _badgesRepo.AddBadgeToRepo(newBadge); }
public void GetAllBadgesTest() { Badge badge = new Badge("123", new List <string>() { "b" }); BadgeRepo repo = new BadgeRepo(); repo.AddBadgeToRepo(badge); Badge badgeTwo = new Badge("124", new List <string>() { "b" }); repo.AddBadgeToRepo(badgeTwo); Console.WriteLine(repo.GetAllBadges().Count); }
public void AddBadgeToRepoTest() { Badge badge = new Badge("123", new List <string>() { "b" }); BadgeRepo repo = new BadgeRepo(); repo.AddBadgeToRepo(badge); Console.WriteLine(repo._badgeRepo.Count); Assert.AreEqual(1, repo._badgeRepo.Count); Badge badgeTwo = new Badge("124", new List <string>() { "a" }); repo.AddBadgeToRepo(badgeTwo); Console.WriteLine(repo._badgeRepo.Count); Assert.AreEqual(2, repo._badgeRepo.Count); }
public void AddBadgeToRepo_ShouldReturnTrue() { BadgeRepo _badges = new BadgeRepo(); Badge firstBadge = new Badge(1, new List <string> { "A5", "B7", "C9" }); bool actual = _badges.AddBadgeToRepo(firstBadge); Assert.IsTrue(actual); }
public void MyTestMethod() { Badge content = new Badge(5, new List <string> { "A5", "B7", "C9" }); BadgeRepo repo = new BadgeRepo(); repo.AddBadgeToRepo(content); Dictionary <int, List <string> > fullRepo = repo.GetAllBadges(); bool directoryHasContents = fullRepo.ContainsKey(content.BadgeID); Assert.IsTrue(directoryHasContents); }
public void DoesBadgeIDExistTest() { Badge badge = new Badge("123", new List <string>() { "b" }); BadgeRepo repo = new BadgeRepo(); repo.AddBadgeToRepo(badge); bool boolOne = repo.DoesBadgeIDExist("123"); Assert.AreEqual(true, boolOne); Assert.IsTrue(repo.DoesBadgeIDExist("123")); bool boolTwo = repo.DoesBadgeIDExist("124"); Assert.AreEqual(false, boolTwo); Assert.IsFalse(repo.DoesBadgeIDExist("124")); }
public void UpdateBadgeByID_ShouldReturnTrue() { BadgeRepo _badges = new BadgeRepo(); Badge firstBadge = new Badge(1, new List <string> { "A5", "B7", "C9" }); _ = _badges.AddBadgeToRepo(firstBadge); // c# discard // it essentially is a way for us to still catch the value but we will never use it so it get's thrown away bool updated = _badges.UpdateBadgeByID(1, new List <string> { "A2", "B6", "C5" }); Assert.IsTrue(updated); }