コード例 #1
0
 private void AssertThatEachElementIsEqualPost(BattingPost battingPost, BattingPostStats battingPostStats)
 {
     Assert.That(battingPostStats.PlayerId, Is.EqualTo(battingPost.PlayerId));
     Assert.That(battingPostStats.YearId, Is.EqualTo(battingPost.YearId));
     Assert.That(battingPostStats.Round, Is.EqualTo(battingPost.Round));
     Assert.That(battingPostStats.TeamId, Is.EqualTo(battingPost.TeamId));
     Assert.That(battingPostStats.LgId, Is.EqualTo(battingPost.LgId));
     Assert.That(battingPostStats.G, Is.EqualTo(battingPost.G));
     Assert.That(battingPostStats.Ab, Is.EqualTo(battingPost.Ab));
     Assert.That(battingPostStats.R, Is.EqualTo(battingPost.R));
     Assert.That(battingPostStats.H, Is.EqualTo(battingPost.H));
     Assert.That(battingPostStats.X2b, Is.EqualTo(battingPost.X2b));
     Assert.That(battingPostStats.X3b, Is.EqualTo(battingPost.X3b));
     Assert.That(battingPostStats.Hr, Is.EqualTo(battingPost.Hr));
     Assert.That(battingPostStats.Rbi, Is.EqualTo(battingPost.Rbi));
     Assert.That(battingPostStats.Sb, Is.EqualTo(battingPost.Sb));
     Assert.That(battingPostStats.Cs, Is.EqualTo(battingPost.Cs));
     Assert.That(battingPostStats.Bb, Is.EqualTo(battingPost.Bb));
     Assert.That(battingPostStats.So, Is.EqualTo(battingPost.So));
     Assert.That(battingPostStats.Ibb, Is.EqualTo(battingPost.Ibb));
     Assert.That(battingPostStats.Hbp, Is.EqualTo(battingPost.Hbp));
     Assert.That(battingPostStats.Sh, Is.EqualTo(battingPost.Sh));
     Assert.That(battingPostStats.Sf, Is.EqualTo(battingPost.Sf));
     Assert.That(battingPostStats.Gidp, Is.EqualTo(battingPost.Gidp));
 }
コード例 #2
0
 private void CopyPlayerDataIfPlayerExists(BattingPost battingPost, BattingPostStats battingPostStats)
 {
     if (battingPost.Player != null)
     {
         battingPostStats.NameFirst = battingPost.Player.NameFirst;
         battingPostStats.NameLast  = battingPost.Player.NameLast;
         battingPostStats.NameGiven = battingPost.Player.NameGiven;
     }
 }
コード例 #3
0
        private void AssertGetBattingPostStatsByYearReturnsStats(BattingPost expectedBattingPost)
        {
            var expectedBattingStatsByYear = new BattingPostStats();

            _mockMapper.Setup(mockBattingMapper => mockBattingMapper.Map(expectedBattingPost)).Returns(expectedBattingStatsByYear);

            var actualBattingLeaderboardStats = _service.GetBattingPostStatsByYear(expectedBattingPost.YearId);

            Assert.That(actualBattingLeaderboardStats.ElementAt(0), Is.EqualTo(expectedBattingStatsByYear));
        }
コード例 #4
0
        private void AssertGetBattingPostStatsReturnsStats(BattingPost expectedBattingPost)
        {
            var expectedBattingPostStats = new BattingPostStats();

            _mockMapper.Setup(mockBattingMapper => mockBattingMapper.Map(expectedBattingPost)).Returns(expectedBattingPostStats);

            var actualBatting = _service.GetBattingPostStats(expectedBattingPost.PlayerId);

            Assert.That(actualBatting.ElementAt(0), Is.EqualTo(expectedBattingPostStats));
        }
コード例 #5
0
        public void MapCopiesDataFromBattingPostToBattingPostStats()
        {
            BattingPost      battingPost      = GenerateBattingPostWithoutNullValues();
            BattingPostStats battingPostStats = _mapper.Map(battingPost);

            AssertThatEachElementIsEqualPost(battingPost, battingPostStats);

            BattingPost      battingWithNull      = GenerateBattingPostWithNullValues();
            BattingPostStats battingStatsWithNull = _mapper.Map(battingWithNull);

            AssertThatEachElementIsEqualPost(battingWithNull, battingStatsWithNull);
        }
コード例 #6
0
        private void AssertGetBattingPostStatsReturnsStatsWithDuplicateId(BattingPost firstEntry, BattingPost secondEntry)
        {
            var firstEntryStats  = new BattingPostStats();
            var secondEntryStats = new BattingPostStats();

            _mockMapper.Setup(mockBattingMapper => mockBattingMapper.Map(firstEntry)).Returns(firstEntryStats);
            _mockMapper.Setup(mockBattingMapper => mockBattingMapper.Map(secondEntry)).Returns(secondEntryStats);

            var actualBatting = _service.GetBattingPostStats(firstEntry.PlayerId);

            Assert.That(actualBatting.ElementAt(0), Is.EqualTo(firstEntryStats));
            Assert.That(actualBatting.ElementAt(1), Is.EqualTo(secondEntryStats));
        }
コード例 #7
0
        public void CreateFakeData(BaseballDBContext database)
        {
            _firstPersonPost = new BattingPost()
            {
                YearId   = 2000,
                Hr       = 20,
                Ab       = 100,
                PlayerId = "id",
                Round    = "WC"
            };

            _secondPersonPost = new BattingPost()
            {
                YearId   = 2000,
                Hr       = 10,
                Ab       = 200,
                PlayerId = "anotherId",
                Round    = "WS"
            };

            _thirdPersonPost = new BattingPost()
            {
                YearId   = 1999,
                Hr       = 18,
                Ab       = 99,
                PlayerId = "id",
                Round    = "WC"
            };

            _fourthPersonPost = new BattingPost()
            {
                YearId   = 1998,
                Hr       = 18,
                Ab       = 20,
                PlayerId = "fourthId",
                Round    = "WS",
                Player   = new People()
                {
                    PlayerId  = "fourthId",
                    NameFirst = "first",
                    NameGiven = "first middle",
                    NameLast  = "last"
                }
            };

            _database.Add(_firstPersonPost);
            _database.Add(_secondPersonPost);
            _database.Add(_thirdPersonPost);
            _database.Add(_fourthPersonPost);
            _database.SaveChanges();
        }
コード例 #8
0
        public BattingPostStats Map(BattingPost battingPost)
        {
            var battingPostStats = new BattingPostStats()
            {
                PlayerId = battingPost.PlayerId,
                YearId   = battingPost.YearId,
                Round    = battingPost.Round,
                TeamId   = battingPost.TeamId,
                LgId     = battingPost.LgId
            };

            CopyPlayerDataIfPlayerExists(battingPost, battingPostStats);
            CopyNullableStats(battingPost, battingPostStats);

            _calculator.CalculateStats(battingPostStats);

            return(battingPostStats);
        }
コード例 #9
0
 private void CopyNullableStats(BattingPost batting, BattingPostStats battingStats)
 {
     battingStats.G    = batting.G;
     battingStats.Ab   = batting.Ab;
     battingStats.R    = batting.R;
     battingStats.H    = batting.H;
     battingStats.X2b  = batting.X2b;
     battingStats.X3b  = batting.X3b;
     battingStats.Hr   = batting.Hr;
     battingStats.Rbi  = batting.Rbi;
     battingStats.Sb   = batting.Sb;
     battingStats.Cs   = batting.Cs;
     battingStats.Bb   = batting.Bb;
     battingStats.So   = batting.So;
     battingStats.Ibb  = batting.Ibb;
     battingStats.Hbp  = batting.Hbp;
     battingStats.Sh   = batting.Sh;
     battingStats.Sf   = batting.Sf;
     battingStats.Gidp = batting.Gidp;
 }
コード例 #10
0
ファイル: Baseball.xaml.cs プロジェクト: timotrob/VelocityDB
 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;
     }
 }