Esempio n. 1
0
        public void SavingOdds()
        {
            var database    = new OddsDatabase(this);
            var competition = new Models.Betfair.Response.Competition {
                Id = "compId", Name = "compName"
            };
            var homeTeam = new Models.Betfair.Response.Team {
                SelectionId = "home", Name = "homeTeamName", Metadata = new Metadata {
                    Id = "123456"
                }, Odds = 3.5m
            };
            var awayTeam = new Models.Betfair.Response.Team {
                SelectionId = "away", Name = "awayTeamName", Metadata = new Metadata {
                    Id = "987654"
                }, Odds = 12m
            };
            var source = new Market {
                Id = "id", Competition = competition, StartTime = DateTime.UtcNow, Teams = new[] { homeTeam, awayTeam }
            };
            var odds = MatchOdds.From(source);

            database.Save(odds);

            Assert.Equal(expectedSql, _sql);
            Assert.Same(odds, _odds);
        }
        public void IsMappedCorrectly()
        {
            var competition = new Models.Betfair.Response.Competition {
                Id = "compId", Name = "compName"
            };
            var homeTeam = new Models.Betfair.Response.Team {
                SelectionId = "home", Name = "homeTeamName", Metadata = new Metadata {
                    Id = "123456"
                }, Odds = 3.5m
            };
            var awayTeam = new Models.Betfair.Response.Team {
                SelectionId = "away", Name = "awayTeamName", Metadata = new Metadata {
                    Id = "987654"
                }, Odds = 12m
            };
            var source = new Market {
                Id = "id", Competition = competition, StartTime = DateTime.UtcNow, Teams = new[] { homeTeam, awayTeam }
            };

            var result = MatchOdds.From(source);

            Assert.Equal(source.Id, result.Id);
            Assert.Equal(competition.Id, result.CompetitionId);
            Assert.Equal(competition.Name, result.CompetitionName);
            Assert.Equal(source.StartTime, result.Date);
            Assert.Equal(homeTeam.Id, result.HomeTeamId);
            Assert.Equal(awayTeam.Id, result.AwayTeamId);
            Assert.Equal(homeTeam.Name, result.HomeTeamName);
            Assert.Equal(awayTeam.Name, result.AwayTeamName);
            Assert.Equal(homeTeam.Odds, result.HomeTeamOddsDecimal);
            Assert.Equal(awayTeam.Odds, result.AwayTeamOddsDecimal);
            Assert.Equal(OddsConverter.ToFractional(homeTeam.Odds), result.HomeTeamOdds);
            Assert.Equal(OddsConverter.ToFractional(awayTeam.Odds), result.AwayTeamOdds);
        }
        private static Market BuildMarket(string marketId)
        {
            var homeTeam = new Models.Betfair.Response.Team {
                Metadata = new Metadata {
                    Id = "home"
                }, Name = "home", Odds = 3.8m
            };
            var awayTeam = new Models.Betfair.Response.Team {
                Metadata = new Metadata {
                    Id = "away"
                }, Name = "away", Odds = 6.4m
            };
            var competition = new Models.Betfair.Response.Competition {
                Id = "comp", Name = "comp"
            };

            return(new Market
            {
                Id = marketId,
                StartTime = DateTime.UtcNow,
                Competition = competition,
                Teams = new[] { homeTeam, awayTeam }
            });
        }
        public OddsImporterTests()
        {
            var competition = new Models.Betfair.Response.Competition {
                Id = "compId", Name = "compName"
            };
            var homeTeam = new Models.Betfair.Response.Team {
                SelectionId = "home", Name = "homeTeamName", Metadata = new Metadata {
                    Id = "123456"
                }, Odds = 3.5m
            };
            var awayTeam = new Models.Betfair.Response.Team {
                SelectionId = "away", Name = "awayTeamName", Metadata = new Metadata {
                    Id = "987654"
                }, Odds = 12m
            };
            var source = new Market {
                Id = "id", Competition = competition, StartTime = DateTime.UtcNow, Teams = new[] { homeTeam, awayTeam }
            };

            _oddsReturned = new[] { MatchOdds.From(source) };
            var importer = new OddsImporter(this, this);

            importer.Import().Wait();
        }