public void GetById_ShouldReturnCorrectItem() { //ACT BadgeItems searchResult = _repo.GetBadgeById(33245); //ASSERT Assert.AreEqual(_content, searchResult); }
public void Arrange() { _repo = new BadgeItemsRepository(); _content = new BadgeItems(33245, new List <string>() { "A1", "A2", "A3" }); _repo.AddNewBadge(_content); }
public void AddBadge_ShouldGetCorrectBoolean() { //ARRANGE BadgeItems newBadge = new BadgeItems(); BadgeItemsRepository repo = new BadgeItemsRepository(); //ACT bool addResult = repo.AddNewBadge(newBadge); //ASSERT Assert.IsTrue(addResult); }
private void EnterNewBadge() { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Clear(); BadgeItems content = new BadgeItems(); Console.WriteLine("What is the number on the badge:"); Console.ForegroundColor = ConsoleColor.Gray; content.BadgeId = int.Parse(Console.ReadLine()); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("List a door that it needs access to:"); Console.ForegroundColor = ConsoleColor.Gray; List <string> newList = new List <string>(); string input = Console.ReadLine(); newList.Add(input); bool keepRunning = true; while (keepRunning) { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Any other doors(y/n)?"); Console.ForegroundColor = ConsoleColor.Gray; string answer = Console.ReadLine(); if (answer.ToLower() == "y") { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("List a door that it needs access to:"); Console.ForegroundColor = ConsoleColor.Gray; input = Console.ReadLine(); newList.Add(input); } else if (answer.ToLower() == "n") { keepRunning = false; } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Opton is invalid."); } } content.DoorName = newList; _badgeItemsRepo.AddNewBadge(content); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
private void SeedContent() { string a1 = "A1"; string a4 = "A4"; string a5 = "A5"; string a7 = "A7"; string b1 = "B1"; string b2 = "B2"; BadgeItems badgeOne = new BadgeItems(12345, new List <string> { a7 }); BadgeItems badgeTwo = new BadgeItems(22345, new List <string> { a1, a4, b1, b2 }); BadgeItems badgeThree = new BadgeItems(32345, new List <string> { a4, a5 }); _badgeItemsRepo.AddNewBadge(badgeOne); _badgeItemsRepo.AddNewBadge(badgeTwo); _badgeItemsRepo.AddNewBadge(badgeThree); }
//load badges. pass in grid and progressbar to change visibility public async void loadBadges(Grid badgeGrid, ProgressBar progressBar) { //url to load badges var url = "https://api.foursquare.com/v2/users/self/badges?oauth_token=" + App.accessToken + "&v=" + App.date; //string response string response = null; //error for web call bool error = false; //BadgeClass BadgeClass.RootObject badge = null; //try catch to catch any web errors try { response = await client.GetStringAsync(url); } catch { //set error to true when exception is caught error = true; } //if there was no error then deserialize if (!error) { //bool for json errors bool jsonError = false; try { //deserialize badge = JsonConvert.DeserializeObject <BadgeClass.RootObject>(response); } catch { jsonError = true; } //if no error then let us continue if (!jsonError) { //badges are weird in their return. so we get a count of total badges given and add them up int counter = 0; int groupCount = badge.response.sets.groups.Count; for (int x = 0; x < groupCount; x++) { //going to count all badges combined in 3 groups counter += badge.response.sets.groups[x].items.Count; } List <BadgeItem> tempItems = new List <BadgeItem>(); tempItems.Add(new BadgeItem() { image = badge.response.badges.__invalid_name__4c4f08667a0803bbac202ab7.image.prefix + badge.response.badges.__invalid_name__4c4f08667a0803bbac202ab7.image.sizes[2] + badge.response.badges.__invalid_name__4c4f08667a0803bbac202ab7.image.name , name = badge.response.badges.__invalid_name__4c4f08667a0803bbac202ab7.name }); for (int x = 0; x < groupCount; x++) { BadgeItems.Add(new BadgeItem() { name = badge.response.sets.groups[x].name, image = badge.response.sets.groups[x].image.prefix + badge.response.sets.groups[x].image.sizes[2] + badge.response.sets.groups[x].image.name }); } Deployment.Current.Dispatcher.BeginInvoke(() => { badgeGrid.Visibility = Visibility.Visible; progressBar.Visibility = Visibility.Collapsed; progressBar.IsEnabled = false; }); } } }
public void EditBadge() { Console.Clear(); Dictionary <int, List <string> > listOfBadges = _badgeItemsRepo.GetAllBadges(); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("What is the badge number to update?"); Console.ForegroundColor = ConsoleColor.Gray; int badgeId = int.Parse(Console.ReadLine()); BadgeItems foundContent = _badgeItemsRepo.GetBadgeById(badgeId); if (foundContent != null) { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine($"{foundContent.BadgeId} has access to doors:"); Console.ForegroundColor = ConsoleColor.Gray; foreach (var doorList in listOfBadges[badgeId]) { Console.WriteLine(doorList); } Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("What would you like to do?"); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("1. Remove a door\n" + "2. Add a door"); Console.ForegroundColor = ConsoleColor.Gray; string option = Console.ReadLine(); if (option == "1") { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Which door would you like to remove?"); Console.ForegroundColor = ConsoleColor.Gray; string input = Console.ReadLine(); foundContent.DoorName.Remove(input); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Door Removed"); Console.WriteLine($"{foundContent.BadgeId} has access to doors:"); Console.ForegroundColor = ConsoleColor.Gray; foreach (var doorList in listOfBadges[badgeId]) { Console.WriteLine(doorList); } } else if (option == "2") { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Which door would you like to add?"); Console.ForegroundColor = ConsoleColor.Gray; string input = Console.ReadLine(); foundContent.DoorName.Add(input); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Door Added"); Console.WriteLine($"{foundContent.BadgeId} has access to doors:"); Console.ForegroundColor = ConsoleColor.Gray; foreach (var doorList in listOfBadges[badgeId]) { Console.WriteLine(doorList); } } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Invalid Entry"); } } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Badge number not found..."); } Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }