예제 #1
0
        public async Task Synchronise(ILogger logger = null)
        {
            var fixtures = await FixtureCollection.RetrieveFrom(fixtureProvider, DateTime.UtcNow, DateTime.Today.AddDays(7));

            fixtures.UpdateOdds(oddsSource, logger);
            fixtures.SaveTo(fixtureDatabase);
        }
예제 #2
0
        public void Create(Type t, FixtureCollection fixtures)
        {
            // get framework
            IFramework framework = FrameworkFactory.FromType(t);

            if (framework == null)
            {
                return;
            }

            // get test attribute
            Object fixtureAttribute = TypeHelper.TryGetFirstCustomAttribute(t, framework.TestFixtureAttributeType);

            if (fixtureAttribute == null)
            {
                return;
            }

            // create run
            bool       ignored  = TypeHelper.HasCustomAttribute(t, framework.IgnoreAttributeType);
            MethodInfo setUp    = TypeHelper.GetAttributedMethod(t, framework.TestFixtureSetUpAttributeType);
            MethodInfo tearDown = TypeHelper.GetAttributedMethod(t, framework.TestFixtureTearDownAttributeType);

            Fixture fixture = new Fixture(t, this.CreateRun(framework), setUp, tearDown, ignored);

            fixtures.Add(fixture);
        }
예제 #3
0
        protected void ExploreType(Type type)
        {
            // it is a class
            // it is not an interface
            // it is not abstract
            if (!type.IsClass || type.IsInterface || type.IsAbstract)
            {
                return;
            }

            // check if filter ok
            if (!this.Filter.Filter(type))
            {
                return;
            }

            // look if any of the fixture attribute can return a run
            FixtureCollection fixs = new FixtureCollection();

            foreach (IFixtureFactory factory in this.FixtureFactories)
            {
                fixs.Clear();
                factory.Create(type, fixs);
                if (fixs.Count != 0)
                {
                    this.fixtureGraph.AddFixtureRange(fixs);
                    break;
                }
            }
        }
예제 #4
0
        public static async Task Run([TimerTrigger("0 30 */6 * * *")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"[BEGIN] ResultsImporter: {DateTime.Now}");
            var serviceProvider   = new ServiceCollection().AddHttpClient().BuildServiceProvider();
            var httpClientFactory = serviceProvider.GetService <IHttpClientFactory>();

            var settings = AppSettings.Configure();

            using (var sqlConnection = new SqlConnection(settings.Database.ConnectionString))
            {
                sqlConnection.Open();
                var databaseConnection = new DatabaseConnection(sqlConnection);

                IProvider <Competition> competitionDb = new CompetitionDatabase(databaseConnection);
                IDatabase <Team>        teamDb        = new TeamDatabase(databaseConnection);
                IGameweekDatabase       gameweekDb    = new GameweekDatabase(databaseConnection);

                var fixtureMapper   = new Mappers.ApiFootball.FixtureMapper(competitionDb, teamDb, gameweekDb);
                var fixtureProvider = new ApiFootballFixtureProvider(httpClientFactory, settings.Api.AuthToken, fixtureMapper);

                var fixtureDb = new FixtureDatabase(databaseConnection);
                var today     = DateTime.Today;
                var fixtures  = await FixtureCollection.RetrieveFrom(fixtureProvider, today.AddDays(-2), today);

                log.LogInformation($"Retrieved {fixtures.Count()} fixtures");
                fixtures.SaveTo(fixtureDb);
            }
            log.LogInformation($"[COMPLETE] ResultsImporter: {DateTime.Now}");
        }
예제 #5
0
 public void AddFixtureRange(FixtureCollection fixtures)
 {
     if (fixtures == null)
     {
         throw new ArgumentNullException("fixtures");
     }
     foreach (Fixture fixture in fixtures)
     {
         AddFixture(fixture);
     }
 }
예제 #6
0
        public void Create(Type t, FixtureCollection fixtures)
        {
            MethodInfo mi = this.GetMain(t, new Type[] { typeof(string[]) });

            if (mi == null)
            {
                mi = this.GetMain(t, Type.EmptyTypes);
            }
            if (mi == null)
            {
                return;
            }

            // create run
            SSCLIRun run     = new SSCLIRun(mi, this.successReturnCode);
            Fixture  fixture = new Fixture(t, run, null, null, false);

            fixtures.Add(fixture);
        }
예제 #7
0
        public void Create(Type t, FixtureCollection fixtures)
        {
            if (!t.IsClass)
            {
                return;
            }
            if (t.IsAbstract)
            {
                return;
            }
            if (!t.Name.EndsWith(this.fixtureNameSuffix))
            {
                return;
            }


            MethodInfo setup    = t.GetMethod(this.testFixtureSetUpName, Type.EmptyTypes);
            MethodInfo tearDown = t.GetMethod(this.testFixtureTearDownName, Type.EmptyTypes);

            Fixture fixture = new Fixture(t, this.run, setup, tearDown, false);

            fixtures.Add(fixture);
        }
예제 #8
0
        public void Create(Type t, FixtureCollection fixtures)
        {
            MethodInfo setUp            = null;
            MethodInfo tearDown         = null;
            bool       setUpSearched    = false;
            bool       tearDownSearched = false;

            bool ignored = TypeHelper.HasCustomAttribute(t, typeof(IgnoreAttribute));

            foreach (TestFixturePatternAttribute attr in t.GetCustomAttributes(typeof(TestFixturePatternAttribute), true))
            {
                IRun run = null;
                try
                {
                    run = attr.GetRun();
                }
                catch (Exception ex)
                {
                    run = new FixtureFailedLoadingRun(t, ex);
                }
                if (!setUpSearched)
                {
                    setUp         = TypeHelper.GetAttributedMethod(t, typeof(TestFixtureSetUpAttribute));
                    setUpSearched = true;
                }
                if (!tearDownSearched)
                {
                    tearDown         = TypeHelper.GetAttributedMethod(t, typeof(TestFixtureTearDownAttribute));
                    tearDownSearched = true;
                }

                Fixture fixture = new Fixture(t, run, setUp, tearDown, ignored);
                fixture.TimeOut        = attr.GetTimeOut();
                fixture.ApartmentState = attr.ApartmentState;
                fixtures.Add(fixture);
            }
        }