public void CreateFakeData(BaseballDBContext database) { _firstPerson = new Fielding() { Pos = "2B", YearId = 2000, A = 20, E = 100, PlayerId = "id" }; _secondPerson = new Fielding() { Pos = "P", YearId = 2001, A = 10, E = 200, PlayerId = "anotherId" }; _duplicatePerson = new Fielding() { Pos = "C", YearId = 1999, A = 18, E = 99, PlayerId = "id" }; _database.Add(_firstPerson); _database.Add(_secondPerson); _database.Add(_duplicatePerson); _database.SaveChanges(); }
private void DeserializeAndAddFielding(string json, BarStoolLeagueContext context) { var fielding = new Fielding(); JsonConvert.PopulateObject(json, fielding); context.Fielding.Add(fielding); }
public void AssertGetFieldingStatsReturnsStats(Fielding expectedPerson) { var expectedPersonStats = new FieldingStats(); _mockMapper.Setup(mockFieldingMapper => mockFieldingMapper.Map(expectedPerson)).Returns(expectedPersonStats); var actualFielding = _service.GetFieldingStats(expectedPerson.PlayerId); Assert.That(actualFielding.ElementAt(0), Is.EqualTo(expectedPersonStats)); }
public void AssertGetFieldingStatsReturnsStatsWithDuplicateId(Fielding firstEntry, Fielding secondEntry) { var firstEntryStats = new FieldingStats(); var secondEntryStats = new FieldingStats(); _mockMapper.Setup(mockFieldingMapper => mockFieldingMapper.Map(firstEntry)).Returns(firstEntryStats); _mockMapper.Setup(mockFieldingMapper => mockFieldingMapper.Map(secondEntry)).Returns(secondEntryStats); var actualPeople = _service.GetFieldingStats(firstEntry.PlayerId); Assert.That(actualPeople.ElementAt(0), Is.EqualTo(firstEntryStats)); Assert.That(actualPeople.ElementAt(1), Is.EqualTo(secondEntryStats)); }
public void MapCopiesDataFromFieldingToFieldingStats() { Fielding fielding = GenerateFieldingWithoutNullValues(); FieldingStats fieldingStats = _mapper.Map(fielding); AssertThatEachElementIsEqual(fielding, fieldingStats); Fielding fieldingWithNull = GenerateFieldingWithNullValues(); FieldingStats fieldingStatsWithNull = _mapper.Map(fieldingWithNull); AssertThatEachElementIsEqual(fieldingWithNull, fieldingStatsWithNull); }
private void ConvertOptionalParamsToNonNullable(Fielding fielding, FieldingStats fieldingStats) { fieldingStats.G = fielding.G; fieldingStats.Gs = fielding.Gs; fieldingStats.InnOuts = fielding.InnOuts; fieldingStats.Po = fielding.Po; fieldingStats.A = fielding.A; fieldingStats.E = fielding.E; fieldingStats.Dp = fielding.Dp; fieldingStats.Pb = fielding.Pb; fieldingStats.Wp = fielding.Wp; fieldingStats.Sb = fielding.Sb; fieldingStats.Cs = fielding.Cs; fieldingStats.Zr = fielding.Zr; }
public FieldingStats Map(Fielding fielding) { var fieldingStats = new FieldingStats() { PlayerId = fielding.PlayerId, YearId = fielding.YearId, Stint = fielding.Stint, TeamId = fielding.TeamId, LgId = fielding.LgId, Pos = fielding.Pos }; ConvertOptionalParamsToNonNullable(fielding, fieldingStats); return(fieldingStats); }
private void AssertThatEachElementIsEqual(Fielding fielding, FieldingStats fieldingStats) { Assert.That(fieldingStats.PlayerId, Is.EqualTo(fielding.PlayerId)); Assert.That(fieldingStats.YearId, Is.EqualTo(fielding.YearId)); Assert.That(fieldingStats.Stint, Is.EqualTo(fielding.Stint)); Assert.That(fieldingStats.TeamId, Is.EqualTo(fielding.TeamId)); Assert.That(fieldingStats.LgId, Is.EqualTo(fielding.LgId)); Assert.That(fieldingStats.G, Is.EqualTo(fielding.G)); Assert.That(fieldingStats.Pos, Is.EqualTo(fielding.Pos)); Assert.That(fieldingStats.Gs, Is.EqualTo(fielding.Gs)); Assert.That(fieldingStats.InnOuts, Is.EqualTo(fielding.InnOuts)); Assert.That(fieldingStats.Po, Is.EqualTo(fielding.Po)); Assert.That(fieldingStats.A, Is.EqualTo(fielding.A)); Assert.That(fieldingStats.E, Is.EqualTo(fielding.E)); Assert.That(fieldingStats.Dp, Is.EqualTo(fielding.Dp)); Assert.That(fieldingStats.Pb, Is.EqualTo(fielding.Pb)); Assert.That(fieldingStats.Sb, Is.EqualTo(fielding.Sb)); Assert.That(fieldingStats.Cs, Is.EqualTo(fielding.Cs)); Assert.That(fieldingStats.Wp, Is.EqualTo(fielding.Wp)); Assert.That(fieldingStats.Zr, Is.EqualTo(fielding.Zr)); }
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; } }