Esempio n. 1
0
            public void UpdatesAnExistingMatch()
            {
                //Arrange
                this.matches   = new List <E.Match>();
                this.matchDate = new DateTime(2013, 02, 02);

                var matchToCheck = new E.Match()
                {
                    TeamsPlayerA = new E.TeamPlayer {
                        Name = "QPR"
                    },
                    TeamsPlayerB = new E.TeamPlayer {
                        Name = "Norwich"
                    },
                    MatchDate = this.matchDate.AddHours(15) //wrong time
                };

                matches.Add(matchToCheck);

                this.webRepositoryProvider = new ManifestWebRepositoryProvider();

                this.mockFixtureRepository = BuildFixtureRepository.Create()
                                             .HasTheSkySportsURL(this.matchDate)
                                             .HasGetAliasWhichReturnsItself()
                                             .CanAddOrUpdateMatches(matches)
                                             .HasFootballTournamentEvents();

                this.mockStoredProcRepository = new Mock <ISqlLinqStoredProceduresRepository>();

                var footballFixtureStrategy = new TestableFootballFixtureStrategy(this.mockFixtureRepository,
                                                                                  this.mockStoredProcRepository, this.webRepositoryProvider);

                //Act
                footballFixtureStrategy.UpdateFixtures(this.matchDate);

                //Assert
                //Hasn't been added twice
                Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "QPR" && x.TeamsPlayerB.Name == "Norwich"));
                //Time has been updated
                Assert.AreEqual(this.matchDate.AddHours(12.75), this.matches.First(x => x.TeamsPlayerA.Name == "QPR" && x.TeamsPlayerB.Name == "Norwich").MatchDate);
            }
Esempio n. 2
0
            public void CreatesANewCollectionOfMatches()
            {
                //Arrange
                this.matches               = new List <E.Match>();
                this.matchDate             = new DateTime(2013, 02, 02);
                this.webRepositoryProvider = new ManifestWebRepositoryProvider();

                this.mockFixtureRepository = BuildFixtureRepository.Create()
                                             .HasTheSkySportsURL(this.matchDate)
                                             .HasGetAliasWhichReturnsItself()
                                             .CanAddOrUpdateMatches(matches)
                                             .HasFootballTournamentEvents();

                this.mockStoredProcRepository = new Mock <ISqlLinqStoredProceduresRepository>();

                var footballFixtureStrategy = new TestableFootballFixtureStrategy(this.mockFixtureRepository,
                                                                                  this.mockStoredProcRepository, this.webRepositoryProvider);

                //Act
                footballFixtureStrategy.UpdateFixtures(this.matchDate);

                //Assert
                //We have the right number of matches
                Assert.AreEqual(8, this.matches.Count(x => x.TournamentEvent.Id == 1));  //Prem
                Assert.AreEqual(11, this.matches.Count(x => x.TournamentEvent.Id == 2)); //Champ
                Assert.AreEqual(11, this.matches.Count(x => x.TournamentEvent.Id == 3)); //League 1
                Assert.AreEqual(10, this.matches.Count(x => x.TournamentEvent.Id == 4)); //League 2
                //We have collected the correct dates
                Assert.AreEqual(1, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(12.75)));
                Assert.AreEqual(1, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(17.5)));
                Assert.AreEqual(1, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(17).AddMinutes(20)));
                Assert.AreEqual(37, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(15)));
                //Spot check a few matches
                Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "QPR" && x.TeamsPlayerB.Name == "Norwich"));
                Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "Yeovil" && x.TeamsPlayerB.Name == "Brentford"));
                Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "Cheltenham" && x.TeamsPlayerB.Name == "Torquay"));
            }
      public void CreatesANewCollectionOfMatches()
      {
        //Arrange
        this.matches = new List<E.Match>();
        this.matchDate = new DateTime(2013, 02, 02);
        this.webRepositoryProvider = new ManifestWebRepositoryProvider();

        this.mockFixtureRepository = BuildFixtureRepository.Create()
          .HasTheSkySportsURL(this.matchDate)
          .HasGetAliasWhichReturnsItself()
          .CanAddOrUpdateMatches(matches)
          .HasFootballTournamentEvents();

        this.mockStoredProcRepository = new Mock<ISqlLinqStoredProceduresRepository>();

        var footballFixtureStrategy = new TestableFootballFixtureStrategy(this.mockFixtureRepository,
          this.mockStoredProcRepository, this.webRepositoryProvider);

        //Act
        footballFixtureStrategy.UpdateFixtures(this.matchDate);

        //Assert
        //We have the right number of matches
        Assert.AreEqual(8, this.matches.Count(x => x.TournamentEvent.Id == 1)); //Prem
        Assert.AreEqual(11, this.matches.Count(x => x.TournamentEvent.Id == 2)); //Champ
        Assert.AreEqual(11, this.matches.Count(x => x.TournamentEvent.Id == 3)); //League 1
        Assert.AreEqual(10, this.matches.Count(x => x.TournamentEvent.Id == 4)); //League 2
        //We have collected the correct dates
        Assert.AreEqual(1, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(12.75)));
        Assert.AreEqual(1, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(17.5)));
        Assert.AreEqual(1, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(17).AddMinutes(20)));
        Assert.AreEqual(37, this.matches.Count(x => x.MatchDate == this.matchDate.AddHours(15)));
        //Spot check a few matches
        Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "QPR" && x.TeamsPlayerB.Name == "Norwich"));
        Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "Yeovil" && x.TeamsPlayerB.Name == "Brentford"));
        Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "Cheltenham" && x.TeamsPlayerB.Name == "Torquay"));
      }
      public void UpdatesAnExistingMatch()
      {
        //Arrange
        this.matches = new List<E.Match>();
        this.matchDate = new DateTime(2013, 02, 02);

        var matchToCheck = new E.Match()
        {
          TeamsPlayerA = new E.TeamPlayer { Name = "QPR" },
          TeamsPlayerB = new E.TeamPlayer { Name = "Norwich" },
          MatchDate = this.matchDate.AddHours(15) //wrong time
        };

        matches.Add(matchToCheck);

        this.webRepositoryProvider = new ManifestWebRepositoryProvider();

        this.mockFixtureRepository = BuildFixtureRepository.Create()
          .HasTheSkySportsURL(this.matchDate)
          .HasGetAliasWhichReturnsItself()
          .CanAddOrUpdateMatches(matches)
          .HasFootballTournamentEvents();

        this.mockStoredProcRepository = new Mock<ISqlLinqStoredProceduresRepository>();

        var footballFixtureStrategy = new TestableFootballFixtureStrategy(this.mockFixtureRepository,
          this.mockStoredProcRepository, this.webRepositoryProvider);

        //Act
        footballFixtureStrategy.UpdateFixtures(this.matchDate);

        //Assert
        //Hasn't been added twice
        Assert.AreEqual(1, this.matches.Count(x => x.TeamsPlayerA.Name == "QPR" && x.TeamsPlayerB.Name == "Norwich"));
        //Time has been updated
        Assert.AreEqual(this.matchDate.AddHours(12.75), this.matches.First(x => x.TeamsPlayerA.Name == "QPR" && x.TeamsPlayerB.Name == "Norwich").MatchDate);
      }