public static Option RegisterShip(bool reRegister = false) { ConsoleWriter.ClearScreen(); var lines = File.ReadAllLines(@"UI/maps/5a.RegisterShip.txt"); var drawables = TextEditor.Add.DrawablesAt(lines, 0); var nextLine = drawables.Max(x => x.CoordinateY); var ships = APICollector.ReturnShipsAsync().Where(s => double.Parse(s.ShipLength) <= 150).ToArray(); var shipLines = ships.Select(x => "$ " + x.Model).ToArray(); drawables.AddRange(TextEditor.Add.DrawablesAt(shipLines, nextLine + 3)); TextEditor.Center.ToScreen(drawables, Console.WindowWidth, Console.WindowHeight); var selectionList = new SelectionList <SpaceShip>(ForegroundColor, '$'); selectionList.GetCharPositions(drawables); selectionList.AddSelections(ships); ConsoleWriter.TryAppend(drawables); ConsoleWriter.Update(); var ship = selectionList.GetSelection(); if (reRegister) { DatabaseManagement.AccountManagement.ReRegisterShip(_account, ship); return(Option.Account); } DatabaseManagement.AccountManagement.Register(_account.User, ship, _namepass.accountName, _namepass.password); return(Option.Login); }
public void DoesUserExists_RightInput_ExpectDarthMaul() { ConnectionString = "Insert connection string here."; var user = APICollector.ParseUserAsync("Darth Maul"); var expectedResult = AccountManagement.Exists(user); Assert.True(expectedResult); }
public void ParseShipAsync_RightInput_ExpectCorellia() { var ship = APICollector.ParseShipAsync("YT-1300 light freighter"); var expectedManufacturer = "Corellian Engineering Corporation"; Assert.True(expectedManufacturer == ship.Manufacturer); }
public void ParseUserAsync_RightInput_ExpectBlue() { var user = APICollector.ParseUserAsync("Luke Skywalker"); var expectedEyeColor = "blue"; Assert.True(expectedEyeColor == user.EyeColor); //Assert.Equal(expectedEyeColor, user.eyeColor); }
public void CalculatePrice_RightInput_ExpectPricePerMinuteForCorvette() { ConnectionString = "Insert connection string here."; var ship = APICollector.ParseShipAsync("CR90 corvette"); var price = ParkingManagement.CalculatePrice(ship, 1); decimal expectedPrice = 15; Assert.Equal(expectedPrice, price); }
static void Main(string[] args) { SpaceShip spaceShip = new SpaceShip(); spaceShip.Size = new SpaceShip.ShipSize(30, 100, 20); User user = APICollector.ParseUser("https://swapi.dev/api/people/1/"); Console.WriteLine($"Eye color: {user.Eye_color}\nStarWarsID: {user.ID}"); }
private async void FetchData() { IsProcessing = true; SetInfo("Initializing TestRail WebService connection"); try { if (collector == null) { collector = new APICollector(api); } } catch { SetInfo("ERROR::Could not establish a connection to the WebService" + Environment.NewLine); IsProcessing = false; return; } try { _start = DateTime.Now; SetInfo(Environment.NewLine + "TIMEWATCH::_START_TIME_ " + _start.ToLongTimeString()); SetInfo("Started to fetch TestRail Projects"); var projects = await collector.GetProjectsAsync(); SetInfo("Projects fetch { Found [" + projects.Count() + "] projects }" + Environment.NewLine); CurrentCallBack = 0; MaxCallBack = projects.Count(); foreach (var p in projects) { if (EnableMultitask) { Thread processProject = new Thread(() => ProcessProject(p)) { Priority = ThreadPriority.Highest, IsBackground = true }; processProject.TrySetApartmentState(ApartmentState.MTA); MultiThreadingProjects.Add(processProject); processProject.Start(); } else { await ProcessProjectTask(p); } } } catch (Exception ex) { SetInfo("EXCEPTION::Could not establish a connection to the WebService. Current connections are '" + api.TestRailServer + "' and '" + api.JiraServer + "'"); SetInfo("EXCEPTION::" + ex.Source + Environment.NewLine + ex.Message); SetInfo("Global Log: " + Environment.NewLine + Environment.NewLine + Logger.Log); IsProcessing = false; return; } }
public static User IdentifyWithQuestion(string username, Func <string, string> getSecurityAnswer) { var inputUser = APICollector.ParseUserAsync(username); if (inputUser == null) { return(null); } var(question, answer) = GetSecurityQuestion(inputUser); var inputAnswer = getSecurityAnswer(question); if (inputAnswer.ToLower() == answer.ToLower()) { return(inputUser); } return(null); }