public void MapYearCopiesDataFromPitchingPostAndPlayerToPitchingPostStats() { Pitching pitching = GeneratePitchingWithPlayer(); PitchingStats pitchingLeaderBoardStats = _mapper.Map(pitching); AssertThatEachElementIsEqualWithPlayerValues(pitching, pitchingLeaderBoardStats); }
private void CopyPlayerDataIfPlayerExists(Pitching pitching, PitchingStats pitchingStats) { if (pitching.Player != null) { pitchingStats.NameFirst = pitching.Player.NameFirst; pitchingStats.NameLast = pitching.Player.NameLast; pitchingStats.NameGiven = pitching.Player.NameGiven; } }
public void AssertGetPitchingStatsReturnsStats(Pitching expectedPitching) { var expectedPitchingStats = new PitchingStats(); _mockMapper.Setup(mockPitchingMapper => mockPitchingMapper.Map(expectedPitching)).Returns(expectedPitchingStats); var actualPitching = _service.GetPitchingStats(expectedPitching.PlayerId); Assert.That(actualPitching.ElementAt(0), Is.EqualTo(expectedPitchingStats)); }
private void AssertGetPitchingLeaderboardStatsByYearReturnsStats(Pitching expectedPitching) { var expectedPitchingLeaderboardStats = new PitchingStats(); _mockMapper.Setup(mockPitchingMapper => mockPitchingMapper.Map(expectedPitching)).Returns(expectedPitchingLeaderboardStats); var actualPitchingLeaderboardStats = _service.GetPitchingStatsByYear(expectedPitching.YearId); Assert.That(actualPitchingLeaderboardStats.ElementAt(0), Is.EqualTo(expectedPitchingLeaderboardStats)); }
public void MapCopiesDataFromPitchingToPitchingStats() { Pitching pitching = GeneratePitchingWithoutNullValues(); PitchingStats pitchingStats = _mapper.Map(pitching); AssertThatEachElementIsEqual(pitching, pitchingStats); Pitching pitchingWithNull = GeneratePitchingWithNullValues(); PitchingStats pitchingStatsWithNull = _mapper.Map(pitchingWithNull); AssertThatEachElementIsEqual(pitchingWithNull, pitchingStatsWithNull); }
private void CopyNullableStats(Pitching pitching, PitchingStats pitchingStats) { pitchingStats.W = pitching.W; pitchingStats.L = pitching.L; pitchingStats.G = pitching.G; pitchingStats.Gs = pitching.Gs; pitchingStats.Cg = pitching.Cg; pitchingStats.Sho = pitching.Sho; pitchingStats.Sv = pitching.Sv; pitchingStats.Ipouts = pitching.Ipouts; pitchingStats.H = pitching.H; pitchingStats.Er = pitching.Er; pitchingStats.Hr = pitching.Hr; pitchingStats.Bb = pitching.Bb; pitchingStats.So = pitching.So; pitchingStats.Baopp = pitching.Baopp; pitchingStats.Era = pitching.Era; pitchingStats.Ibb = pitching.Ibb; pitchingStats.Wp = pitching.Wp; pitchingStats.Hbp = pitching.Hbp; pitchingStats.Bk = pitching.Bk; pitchingStats.Bfp = pitching.Bfp; pitchingStats.Gf = pitching.Gf; pitchingStats.R = pitching.R; pitchingStats.Sh = pitching.Sh; pitchingStats.Sf = pitching.Sf; pitchingStats.Gidp = pitching.Gidp; }
public void AssertGetPitchingStatsReturnsStatsWithDuplicateId(Pitching firstEntry, Pitching secondEntry) { var firstEntryStats = new PitchingStats(); var secondEntryStats = new PitchingStats(); _mockMapper.Setup(mockBattingMapper => mockBattingMapper.Map(firstEntry)).Returns(firstEntryStats); _mockMapper.Setup(mockBattingMapper => mockBattingMapper.Map(secondEntry)).Returns(secondEntryStats); var actualPeople = _service.GetPitchingStats(firstEntry.PlayerId); Assert.That(actualPeople.ElementAt(0), Is.EqualTo(firstEntryStats)); Assert.That(actualPeople.ElementAt(1), Is.EqualTo(secondEntryStats)); }
public void CreateFakeData(BaseballDBContext database) { _firstPerson = new Pitching() { YearId = 2000, Hr = 20, W = 10, PlayerId = "id" }; _secondPerson = new Pitching() { YearId = 2000, Hr = 10, W = 3, PlayerId = "anotherId" }; _thirdPerson = new Pitching() { YearId = 1999, Hr = 18, W = 99, PlayerId = "id" }; _fourthPerson = new Pitching() { YearId = 1998, Hr = 18, W = 20, PlayerId = "fourthId", Player = new People() { PlayerId = "fourthId", NameFirst = "first", NameGiven = "first middle", NameLast = "last" } }; _database.Add(_firstPerson); _database.Add(_secondPerson); _database.Add(_thirdPerson); _database.Add(_fourthPerson); _database.SaveChanges(); }
public PitchingStats Map(Pitching pitching) { var pitchingStats = new PitchingStats() { PlayerId = pitching.PlayerId, YearId = pitching.YearId, Stint = pitching.Stint, TeamId = pitching.TeamId, LgId = pitching.LgId, }; CopyPlayerDataIfPlayerExists(pitching, pitchingStats); CopyNullableStats(pitching, pitchingStats); _calculator.CalculateStats(pitchingStats); return(pitchingStats); }
private void AssertThatEachElementIsEqualWithPlayerValues(Pitching pitching, PitchingStats pitchingStats) { Assert.That(pitchingStats.NameFirst, Is.EqualTo(pitching.Player.NameFirst)); Assert.That(pitchingStats.NameGiven, Is.EqualTo(pitching.Player.NameGiven)); Assert.That(pitchingStats.NameLast, Is.EqualTo(pitching.Player.NameLast)); Assert.That(pitchingStats.PlayerId, Is.EqualTo(pitching.PlayerId)); Assert.That(pitchingStats.YearId, Is.EqualTo(pitching.YearId)); Assert.That(pitchingStats.Stint, Is.EqualTo(pitching.Stint)); Assert.That(pitchingStats.TeamId, Is.EqualTo(pitching.TeamId)); Assert.That(pitchingStats.LgId, Is.EqualTo(pitching.LgId)); Assert.That(pitchingStats.W, Is.EqualTo(pitching.W)); Assert.That(pitchingStats.L, Is.EqualTo(pitching.L)); Assert.That(pitchingStats.G, Is.EqualTo(pitching.G)); Assert.That(pitchingStats.Gs, Is.EqualTo(pitching.Gs)); Assert.That(pitchingStats.Cg, Is.EqualTo(pitching.Cg)); Assert.That(pitchingStats.Sho, Is.EqualTo(pitching.Sho)); Assert.That(pitchingStats.Sv, Is.EqualTo(pitching.Sv)); Assert.That(pitchingStats.Ipouts, Is.EqualTo(pitching.Ipouts)); Assert.That(pitchingStats.H, Is.EqualTo(pitching.H)); Assert.That(pitchingStats.Er, Is.EqualTo(pitching.Er)); Assert.That(pitchingStats.Hr, Is.EqualTo(pitching.Hr)); Assert.That(pitchingStats.Bb, Is.EqualTo(pitching.Bb)); Assert.That(pitchingStats.So, Is.EqualTo(pitching.So)); var localBaopp = pitching.Baopp / 100 ?? 0; Assert.That(pitchingStats.Baopp, Is.EqualTo(Math.Round(localBaopp, 2))); var localEra = pitching.Era / 100 ?? 0; Assert.That(pitchingStats.Era, Is.EqualTo(Math.Round(localEra, 2))); Assert.That(pitchingStats.Ibb, Is.EqualTo(pitching.Ibb)); Assert.That(pitchingStats.Wp, Is.EqualTo(pitching.Wp)); Assert.That(pitchingStats.Hbp, Is.EqualTo(pitching.Hbp)); Assert.That(pitchingStats.Bk, Is.EqualTo(pitching.Bk)); Assert.That(pitchingStats.Bfp, Is.EqualTo(pitching.Bfp)); Assert.That(pitchingStats.Gf, Is.EqualTo(pitching.Gf)); Assert.That(pitchingStats.R, Is.EqualTo(pitching.R)); Assert.That(pitchingStats.Sh, Is.EqualTo(pitching.Sh)); Assert.That(pitchingStats.Sf, Is.EqualTo(pitching.Sf)); Assert.That(pitchingStats.Gidp, Is.EqualTo(pitching.Gidp)); }
private void loadButton_Click(object sender, RoutedEventArgs e) { errorMessage.Content = null; try { using (SessionNoServer session = new SessionNoServer(s_systemDir)) { Console.WriteLine($"Running with databases in directory: {session.SystemDirectory}"); session.BeginUpdate(); File.Copy(s_licenseDbFile, System.IO.Path.Combine(session.SystemDirectory, "4.odb"), true); string line; using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Allstar.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { AllStar allStar = new AllStar(line); session.Persist(allStar); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\AllstarFull.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { AllStarFull allStar = new AllStarFull(line); session.Persist(allStar); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Appearances.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Appearances a = new Appearances(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\AwardsManagers.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { AwardsManagers a = new AwardsManagers(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\AwardsPlayers.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { AwardsPlayers a = new AwardsPlayers(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\AwardsShareManagers.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { AwardsShareManagers a = new AwardsShareManagers(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\AwardsSharePlayers.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { AwardsSharePlayers a = new AwardsSharePlayers(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Batting.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Batting a = new Batting(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\BattingPost.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { BattingPost a = new BattingPost(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Fielding.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Fielding a = new Fielding(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\FieldingOF.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { FieldingOF a = new FieldingOF(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\FieldingPost.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { FieldingPost a = new FieldingPost(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\HallOfFame.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { HallOfFame a = new HallOfFame(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\HOFold.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { HOFold a = new HOFold(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Managers.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Managers a = new Managers(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\ManagersHalf.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { ManagersHalf a = new ManagersHalf(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Master.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Master a = new Master(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Pitching.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Pitching a = new Pitching(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\PitchingPost.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { PitchingPost a = new PitchingPost(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Salaries.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Salaries a = new Salaries(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Schools.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Schools a = new Schools(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\SchoolsPlayers.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { SchoolsPlayers a = new SchoolsPlayers(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\SeriesPost.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { SeriesPost a = new SeriesPost(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Teams.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Teams a = new Teams(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\TeamsFranchises.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { TeamsFranchises a = new TeamsFranchises(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\TeamsHalf.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { TeamsHalf a = new TeamsHalf(line); session.Persist(a); } } using (StreamReader stream = new StreamReader(lahman58db.Text + "\\Xref_Stats.csv", true)) { line = stream.ReadLine(); // heading title line while ((line = stream.ReadLine()) != null) { Xref_Stats a = new Xref_Stats(line); session.Persist(a); } } session.Commit(); errorMessage.Content = "Done, databases located in: " + session.SystemDirectory + " View objects using VelocityDBBrowser"; } } catch (Exception ex) { errorMessage.Content = ex.Message == null?ex.ToString() : ex.Message; } }
public void AddToPitchings(Pitching pitching) { base.AddObject("Pitchings", pitching); }
public static Pitching CreatePitching(string playerID, short yearID, short stint) { Pitching pitching = new Pitching(); pitching.playerID = playerID; pitching.yearID = yearID; pitching.stint = stint; return pitching; }
/// <summary> /// A single turn. /// </summary> public void Turn() { if (isUIEnabled) { //InningPanel InGameObjects.inningPanel.UpdateLayout(); //OutPanel InGameObjects.outPanelLayout.ClearLayout(); InGameObjects.outPanelLayout.UpdateLayout(); //BasePanel InGameObjects.basePanel.UpdateLayout(); InGameObjects.basePanel.UpdateStealing(); //ScorePanel InGameObjects.scorePanel.UpdateLayout(); //BoardPanel InGameObjects.boardPanel.UpdateLayout(); //Field_Condition InGameObjects.PlayerUIApply.SetPlayers(true); } //Initializes stealingAttempts array to false. for (int i = 0; i < 4; ++i) { stealingAttempts[i] = false; } //First, determine whether runners in bases attempt to steal base or not. for (int i = 1; i <= 3; ++i) { bool isBaseStealing = BaseRunning.BaseStealDetermine(runnerInBases[i], true); if (isBaseStealing) { Debug.Log("BASE " + i + "TRYING TO STEAL"); //If a runner is going to steal base, change stealingAttempt bool to true. stealingAttempts[i] = true; } } if (isUIEnabled) { //This is a stealingAttempts UI update. InGameObjects.basePanel.UpdateStealing(); } //Then, a pitcher determines whether pick off the ball or not. bool isPickedOff = PickingOff.PickOffDetermine(out int whichBase, true); if (isPickedOff) { Debug.Log("PICK OFF"); //If the pitcher picks off the ball, a pickoff function starts and control goes to ball in play. PickingOff.PickOff(-1, true); BallInPlay(BallInPlayMode.PICKOFF, true, whichBase); return; } else { //If not picked off, pitcher pitches, and sets wildpitch and hitbypitch bool variables. Pitching.Pitch(out bool isWildPitch, out bool isHitByPitch, true); if (isWildPitch) { Debug.Log("WILD PITCHED"); //If a pitcher wild pitched, control goes to ball in play. PitchedWild.WildPitch(currentPitcher); BallInPlay(BallInPlayMode.WILD_PITCH); return; } else { //If not wild pitched, determine wheter a batter swung or not. bool isSwung = AtPlate.SwingDetermine(true); if (isHitByPitch) { //If a batter got a hit-by-pitch ball, advances runner by 1 base, and the turn ends. AtPlate.AddBall(true); return; } else { //If not hit-by-pitch ball, check if a batter swung. if (isSwung) { Debug.Log("He Swings!"); //If swung, determine whether a swing hit or not. bool isHit = Hitting.HitDetermine(true); if (isHit) { //If hit, control goes to ball in play. BallInPlay(BallInPlayMode.NORMAL); return; } else { //If not hit, adds a strike. AtPlate.AddStrike(); return; } } else { //If not swung, determine whether a ball is strike or ball. bool isInStrike = Pitching.InStrikeZoneDetermine(true); if (isInStrike) { //If a ball is in strikezone, adds a strike. AtPlate.AddStrike(); return; } else { //If not in strikezone, adds a ball. AtPlate.AddBall(); return; } } } } } }