public async Task TestWriterStartingInfo() { starshipservice.GetStarships().Returns(new List <StarShip> { new StarShip() }); Executer exc = new Executer(starshipservice, writer, calculator); await exc.Intialize(); writer.Received().Info("Getting starships"); }
public void Run() { ShowHeader(); var quit = false; var starshipsURL = _settings.StarshipsURL; long travelDistance = AskForTheTravelDistance(); (string, string)previousNextUrls = ("", ""); ConsoleNavigation answerNextPage = ConsoleNavigation.Quit; while (!quit) { // Get starships if (!string.IsNullOrEmpty(starshipsURL)) { var ships = _starshipService.GetStarships(starshipsURL); if (ships == null) { Console.WriteLine("Starships not found."); continue; } previousNextUrls = ShowStarships(ships.Result, travelDistance); } // Navigation answerNextPage = AskNextAction(); if (answerNextPage != ConsoleNavigation.Quit) { if (string.IsNullOrEmpty(previousNextUrls.Item1)) { Console.WriteLine(""); } starshipsURL = _starshipService.GetUrl(answerNextPage, previousNextUrls.Item1, previousNextUrls.Item2); } else { quit = true; } } ; }
/// <summary> /// This method is used to initialize this class and get the Starships data from the <see href="https://swapi.co/">API</see> /// </summary> public async Task Intialize() { writer.Info("Getting starships"); starships = await starshipservice.GetStarships(); }
public void GetStarshipsEmptyUrl() { var result = _starshipService.GetStarships("").Result; Assert.Null(result); }