public void CreateManyMethod_WhenPassedValuesAreValid_ShouldCallCorrectly() { // Arrange var createCyclistMock = new Mock <ICreateCyclist>(); var cyclist = new Cyclist() { FirstName = "Ivan", LastName = "Ivanov", Age = 22, TourDeFranceWins = 1, GiroDItaliaWins = 1, VueltaEspanaWins = 1, CurrentTeam = "Segafredo" }; var listOfCyclists = new List <Cyclist>() { cyclist }; // Act createCyclistMock.Object.CreateMany(listOfCyclists); createCyclistMock.Object.CreateMany(listOfCyclists); // Assert createCyclistMock.Verify(x => x.CreateMany(listOfCyclists), Times.Exactly(2)); }
public static IEnumerator RegisterCyclists(Cyclist c) { WWWForm form = new WWWForm(); form.AddField("name", c.name); form.AddField("lastname", c.lastname); form.AddField("birthdate", c.dateOfBirth); form.AddField("regdate", DateTime.Now.ToShortDateString()); form.AddField("bikebrand", c.brandBike); form.AddField("idteam", c.idTeam); UnityWebRequest www = UnityWebRequest.Post("http://localhost/sqlconnect/register_cyclist.php", form); yield return(www.SendWebRequest()); var result = www.downloadHandler.text; if (result == "0") { Debug.Log("Created Cyclist Success"); } else { Debug.Log(www.downloadHandler.text); } }
public void TotalDistanceForOneCyclist() { var cyclist = new Cyclist("Florin", 20, new Cyclometer[] { new Cyclometer(2, 1), new Cyclometer(3, 2), new Cyclometer(4, 3) }); Assert.AreEqual(565.2, cyclist.CalculateTotalDistance()); }
public void TotalDistanceForAllCyclists() { Cyclist[] cyclists = new Cyclist[] { new Cyclist("Florin", 20, new Cyclometer[] { new Cyclometer(2, 1), new Cyclometer(3, 2), new Cyclometer(4, 3) }), new Cyclist("George", 25, new Cyclometer[] { new Cyclometer(3, 1), new Cyclometer(2, 2), new Cyclometer(2, 3) }) }; Assert.AreEqual(1114.7, CalculateTotalDistance(cyclists)); }
public List <Cyclist> GetAll() { var queryData = new SqlQueryData("SELECT * FROM cyclists", QueryType.Reader); var allCyclists = new List <Cyclist>(); try { SqlDataReader reader = crud.Get(queryData); while (reader.Read()) { var cyclist = new Cyclist(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2)); allCyclists.Add(cyclist); } reader.Close(); return(allCyclists); } catch (Exception e) { MessageBox.Show("Unable to retrieve team. " + e.Message, "CyclistRegistration team error type: " + e.GetType(), MessageBoxButton.OK, MessageBoxImage.Error); Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); return(allCyclists); } }
public void Back() { if (teamProccess) { Data.instance.cyclists.Add(new Cyclist(inputName.text, inputLastName.text, inputDateOfBirth.text, inputBrandBike.text, PlayerPrefs.GetString("teamName"))); SceneManager.LoadScene("reg_team"); } else { if (teamSelected.Length > 0) { Cyclist newCyclist = new Cyclist(inputName.text, inputLastName.text, inputDateOfBirth.text, inputBrandBike.text, teamSelected); newCyclist.idTeam = SetIdToCyclist(); StartCoroutine(Data.RegisterCyclists(newCyclist)); } SceneManager.LoadScene("Home"); } }
public Cyclist CreateYoungCyclist(int teamId) { var cyclists = GetCyclists(); var teamYouthAccomodation = _teamService.GetTeams().Where(t => t.Id == teamId).FirstOrDefault().YouthAccomodation; var randomNationality = _dataService.GetRandomNationality(); Cyclist cyclist = new Cyclist { TeamId = teamId, Age = 16, CyclistSpeedHorizontalPotential = RandomFloat(50f, 100f) + teamYouthAccomodation, CyclistSpeedCobblestonesPotential = RandomFloat(50f, 100f) + teamYouthAccomodation, CyclistSpeedDownPotential = RandomFloat(50f, 100f) + teamYouthAccomodation, CyclistSpeedUpPotential = RandomFloat(50f, 100f) + teamYouthAccomodation, CyclistSpeedHorizontal = 50f, CyclistSpeedCobblestones = 50f, CyclistSpeedDown = 50f, CyclistSpeedUp = 50f, Nationality = randomNationality, Name = _dataService.GetRandomFirstName(randomNationality) + " " + _dataService.GetRandomLastName(randomNationality), Id = cyclists.Max(c => c.Id + 1), SelectedForRace = false }; AddMessage($"{cyclist.Name} started at2 {_teamService.GetTeams().Where(t => t.Id == cyclist.TeamId).FirstOrDefault().Name}"); cyclists.Add(cyclist); CreateCyclists(cyclists); return(cyclist); }
public Cyclist Get(int id) { var queryData = new SqlQueryData("SELECT * FROM cyclists WHERE [id] = @id", QueryType.Reader); queryData.AddParameter("@id", SqlDbType.VarChar, Convert.ToString(id)); try { SqlDataReader reader = crud.Get(queryData); while (reader.Read()) { var cyclist = new Cyclist(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2)); return(cyclist); } reader.Close(); return(new Cyclist()); } catch (Exception e) { MessageBox.Show("Unable to retrieve team. " + e.Message, "CyclistRegistration team error type: " + e.GetType(), MessageBoxButton.OK, MessageBoxImage.Error); Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); return(new Cyclist()); } }
public void DetermineTotalDistanceForAllTest() { var cyclists = new Cyclist[] { new Cyclist("Andreea", new int[] { 2, 2 }, 50), new Cyclist("Ciprian", new int[] { 1, 1, 2 }, 50), new Cyclist("Maria", new int[] { 1, 2 }, 50) }; Assert.AreEqual(1727, DetermineTotalDistanceForAll(cyclists)); }
public void GetAverageSpeedForOneCyclist() { var cyclist = new Cyclist("Florin", 20, new Cyclometer[] { new Cyclometer(2, 1), new Cyclometer(3, 2), new Cyclometer(4, 3) }); var result = cyclist.CalculateAverageSpeed(); Assert.AreEqual(188.4, result); }
public void FindBestAvgSpeedTest() { var cyclists = new Cyclist[] { new Cyclist("Andreea", new int[] { 1, 1, 2, 1 }, 50), new Cyclist("Ciprian", new int[] { 1, 2, 2 }, 60), new Cyclist("Maria", new int[] { 1, 1, 1, 2 }, 55) }; Assert.AreEqual("Ciprian", FindCyclistWithBestAvgSpeed(cyclists)); }
public void BestAverageTest() { var cyclists = new Cyclist[] { new Cyclist("Ion", new int[] { 1, 2, 2, 3 }, 30), new Cyclist("Gheorghe", new int[] { 1, 2, 3, 4 }, 24), new Cyclist("Vasile", new int[] { 1, 2, 2, 4 }, 23) }; Assert.AreEqual("Ion", CyclistWithBestAverageSpeed(cyclists)); }
public void TotalDistanceTest() { var cyclists = new Cyclist[] { new Cyclist("Ion", new int[] { 1, 2, 2, 3 }, 30), new Cyclist("Gheorghe", new int[] { 1, 2, 3, 4 }, 24), new Cyclist("Vasile", new int[] { 1, 2, 2, 4 }, 23) }; Assert.AreEqual(2158.3, TotalDistance(cyclists), 1e-1); }
public override int GetHashCode() { int hash = 1; if (unknown_ != null) { hash ^= Unknown.GetHashCode(); } if (unknownMovable_ != null) { hash ^= UnknownMovable.GetHashCode(); } if (unknownUnmovable_ != null) { hash ^= UnknownUnmovable.GetHashCode(); } if (car_ != null) { hash ^= Car.GetHashCode(); } if (van_ != null) { hash ^= Van.GetHashCode(); } if (truck_ != null) { hash ^= Truck.GetHashCode(); } if (bus_ != null) { hash ^= Bus.GetHashCode(); } if (cyclist_ != null) { hash ^= Cyclist.GetHashCode(); } if (motorcyclist_ != null) { hash ^= Motorcyclist.GetHashCode(); } if (tricyclist_ != null) { hash ^= Tricyclist.GetHashCode(); } if (pedestrian_ != null) { hash ^= Pedestrian.GetHashCode(); } if (trafficcone_ != null) { hash ^= Trafficcone.GetHashCode(); } if (MaxDimChangeRatio != 0F) { hash ^= MaxDimChangeRatio.GetHashCode(); } return(hash); }
/// <summary> /// Load car stuff /// </summary> protected override void Initialize() { base.Initialize(); // Load models carModel = new Cyclist(); Level lvl; try { lvl = (Level)Enum.Parse(typeof(Level), startUpParam.MapName); } catch (Exception) { MessageBox.Show("Unsupported Map: " + startUpParam.MapName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Exit(); return; } // Load landscape landscape = new Landscape(lvl); brakeTrackMaterial = new Material("track"); gameScreens.Push(new GameScreen(lvl)); netClient.TellReady(); while (!netClient.CanStartGame()) { Thread.Sleep(10); } startUpParam = netClient.DownloadStartUpParameters(); for (int i = 0; i < startUpParam.Players.Length; i++) { if (startUpParam.Players[i].ID != localUID) { RemotePlayer plr = new RemotePlayer(startUpParam.Players[i]); remotePlayers.Add(plr.ID, plr); } else { carOffset = i / (float)startUpParam.Players.Length; landscape.SetCarToStartPosition(); } } remoteModels = new Cyclist[remotePlayers.Count]; for (int i = 0; i < remotePlayers.Count; i++) { remoteModels[i] = new Cyclist(); } }
public bool Update(Cyclist cyclist) { var queryData = new SqlQueryData("UPDATE cyclists SET name = @name WHERE id = @cyclistId; "); queryData.AddParameter("@name", SqlDbType.VarChar, cyclist.Name); queryData.AddParameter("@cyclistId", SqlDbType.Int, cyclist.Id.ToString()); return(crud.Update(queryData)); }
public void NameAndSecondTest() { var cyclists = new Cyclist[] { new Cyclist("Ion", new int[] { 1, 2, 2, 3 }, 30), new Cyclist("Gheorghe", new int[] { 1, 2, 3, 4 }, 24), new Cyclist("Vasile", new int[] { 1, 2, 2, 4 }, 23) }; int second = 4; Assert.AreEqual("Gheorghe", SecondAndName(cyclists, out second)); }
public void GetMaximRotationForOneCyclist() { var cyclist = new Cyclist("Florin", 20, new Cyclometer[] { new Cyclometer(2, 1), new Cyclometer(3, 2), new Cyclometer(4, 3) }); var result = cyclist.GetMaximRotation(); Assert.AreEqual(4, result.rotations); Assert.AreEqual(3, result.second); }
private void SubmitCyclist_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { CyclistTeam team = (CyclistTeam)TeamsComboBox.SelectedItem; string cyclistName = CyclistName.Text; ICyclistService service = ServiceManager.GetCyclistService(); Cyclist cyclist = new Cyclist(0, cyclistName, team.Id); service.AddCyclist(cyclist); }
static double TotalDistanceForACyclist(Cyclist cyclist) { double distance = 0; for (int i = 0; i < cyclist.records.Length; i++) { distance += DistancePerSecond(cyclist.wheelDiameter, cyclist.records[i]); } return(distance); }
public bool AddCyclist(Cyclist cyclist) { cyclist.Id = cyclistDao.Add(cyclist); if (cyclist.Id > 0) { ViewModelManager.GetCollection().AllCyclists.Add(cyclist); return(true); } return(false); }
public void FindSecondAndNameForMaxSpeedTest() { var cyclists = new Cyclist[] { new Cyclist("Andreea", new int[] { 1, 3, 2, 5, 1 }, 50), new Cyclist("Ciprian", new int[] { 1, 2, 5 }, 60), new Cyclist("Maria", new int[] { 1, 5, 1, 3, 2 }, 65) }; var result = new Result("Maria", 1); Assert.AreEqual(result, FindSecondAndNameForMaxSpeed(cyclists)); }
double DetermineTotalDistanceForACyclist(Cyclist cyclist) { double totalDistance = 0; for (int i = 0; i < cyclist.rotationsPerSecond.Length; i++) { totalDistance += CalculateDistancePerSecond(cyclist.rotationsPerSecond[i], cyclist.wheelDiameter); } return(totalDistance); }
public void GetCyclistWithBestAverageSpeed() { Cyclist[] cyclists = new Cyclist[] { new Cyclist("Florin", 20, new Cyclometer[] { new Cyclometer(2, 1), new Cyclometer(3, 2), new Cyclometer(4, 3) }), new Cyclist("George", 25, new Cyclometer[] { new Cyclometer(3, 1), new Cyclometer(2, 2), new Cyclometer(2, 3) }), new Cyclist("Alex", 22, new Cyclometer[] { new Cyclometer(5, 1), new Cyclometer(4, 2), new Cyclometer(4, 3) }) }; var result = FindCyclistWithBestAverageSpeed(cyclists); Assert.AreEqual("Alex", result); }
public void GetFastestCyclist() { Cyclist[] cyclists = new Cyclist[] { new Cyclist("Florin", 20, new Cyclometer[] { new Cyclometer(2, 1), new Cyclometer(3, 2), new Cyclometer(4, 3) }), new Cyclist("George", 25, new Cyclometer[] { new Cyclometer(3, 1), new Cyclometer(2, 2), new Cyclometer(2, 3) }), new Cyclist("Alex", 22, new Cyclometer[] { new Cyclometer(5, 1), new Cyclometer(4, 2), new Cyclometer(4, 3) }) }; var result = FindFastestCyclist(cyclists); Assert.AreEqual("Alex", result.name); Assert.AreEqual(1, result.second); }
public Game Init() { Console.SetWindowSize(Console.LargestWindowWidth / 2, Console.LargestWindowHeight / 2); var cyclistStateMachine = new UpdateableStateMachine <Cyclist>(); cyclistStateMachine.SetCurrentState(new RestedAndTimeToTrainState(1)); cyclist = new Cyclist(cyclistStateMachine); cyclist.Name = "Froome"; return(Instance); }
static int SecondOfMaxSpeed(Cyclist cyclist) { int second = 0; for (int i = 0; i < cyclist.records.Length; i++) { if (cyclist.records[i] > second) { second = i + 1; } } return(second); }
public Manager CreateFreeManagerFromCyclist(Cyclist cyclist) { var manager = new Manager { Nationality = cyclist.Nationality, Name = cyclist.Name, TeamId = -1, Age = cyclist.Age, Id = cyclist.Id }; return(manager); }
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e) { Cyclist findName = new Cyclist(); var searchText = SearchBar.Text; findName.Name = searchText; listViewName.Items.Clear(); //List<Cyclist> searchName = Parser.CyclistListMaker().Equals(findName); foreach (var name in Parser.CyclistListMaker()) { listViewName.Items.Add(name); } }
int FindSecondForMaxSpeed(Cyclist cyclist) { int second = 0; for (int i = 1; i < cyclist.rotationsPerSecond.Length; i++) { if (cyclist.rotationsPerSecond[i] > cyclist.rotationsPerSecond[second]) { // second = cyclist.rotationsPerSecond[i]; second = i; } } return(second); }