Esempio n. 1
0
        public void TestPerformance()
        {
            string[] tests = { "access-binary-trees" };
            // string[] tests = { "3d-cube", "3d-morph", "3d-raytrace", "access-binary-trees", "access-fannkuch", "access-nbody", "access-nsieve", "bitops-3bit-bits-in-byte", "bitops-bits-in-byte", "bitops-bitwise-and", "bitops-nsieve-bits", "controlflow-recursive", "crypto-aes", "crypto-md5", "crypto-sha1", "date-format-tofte", "date-format-xparb", "math-cordic", "math-partial-sums", "math-spectral-norm", "regexp-dna", "string-base64", "string-fasta", "string-tagcloud", "string-unpack-code", "string-validate-input" };

            var       assembly = Assembly.GetExecutingAssembly();
            Stopwatch sw       = new Stopwatch();

            foreach (var test in tests)
            {
                string script;

                try
                {
                    script = new StreamReader(assembly.GetManifestResourceStream("Jint.Tests.SunSpider." + test + ".js")).ReadToEnd();
                    if (String.IsNullOrEmpty(script))
                    {
                        continue;
                    }
                }
                catch
                {
                    Console.WriteLine("{0}: ignored", test);
                    continue;
                }

                JintEngine jint = Fixtures.CreateJintEngine()
                                  //.SetDebugMode(true)
                                  .DisableSecurity();

                sw.Reset();
                sw.Start();

                jint.Run(script);

                Console.WriteLine("{0}: {1}ms", test, sw.ElapsedMilliseconds);
            }
        }
Esempio n. 2
0
        public Task <IList <Fixtures> > GetFixtures(string Date_Start, string Date_Finish)
        {
            return(Task.Run(() =>
            {
                IList <Fixtures> fixturesResults = new List <Fixtures>();
                if (!string.IsNullOrEmpty(Date_Start) && !string.IsNullOrEmpty(Date_Finish))
                {
                    string burl = NBAAPIConfig.BaseURL;
                    string key = NBAAPIConfig.Key;
                    string urlNBA = $"{burl}?met=Fixtures&APIkey={key}&from={Date_Start}&to={Date_Finish}";
                    string json = networkManager.GetJson(urlNBA);

                    JObject fixturesSearch = JObject.Parse(json);
                    IList <JToken> results = fixturesSearch["result"].Children().ToList();
                    foreach (var result in results)
                    {
                        Fixtures fixturesResult = result.ToObject <Fixtures>();
                        fixturesResults.Add(fixturesResult);
                    }
                }
                return fixturesResults;
            }));
        }
Esempio n. 3
0
        private bool AddInternal(Type type)
        {
            var typeInfo = type.GetTypeInfo();

            if (TestHelper.HasTests(typeInfo) == false)
            {
                return(false);                                         // does not contain any tests, skip it
            }
            var attrs = TestHelper.GetTestFixtureAttributes(typeInfo); // maybe there is no TestFixture attribute

            if (attrs.Count() == 0)
            {
                Fixtures.Add(new TestFixture(typeInfo, null)); // no TestFixture attribute on the class
            }
            else
            {
                foreach (var testFixtureAttribute in attrs)
                {
                    Fixtures.Add(new TestFixture(typeInfo, testFixtureAttribute));
                }
            }

            return(true);
        }
Esempio n. 4
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (version == 0)
            {
                Timer.DelayCall(() =>
                {
                    var deckItem = Fixtures.FirstOrDefault(f => m_WheelItemIDs.Any(listID => listID == f.ItemID));

                    if (deckItem != null)
                    {
                        ShipWheel wheel = new ShipWheel(this, deckItem.ItemID);
                        AddFixture(wheel);

                        wheel.MoveToWorld(new Point3D(deckItem.X, deckItem.Y, deckItem.Z), deckItem.Map);

                        deckItem.Delete();
                        RemoveFixture(deckItem);
                    }
                });
            }
        }
Esempio n. 5
0
    public void PlaceFixture(string objType, Tile tile)
    {
        //TODO: This function assumes 1x1 no rotation objects

        if (!FixturePrototypes.ContainsKey(objType))
        {
            Debug.LogError("FixtureProtoypes does not contain a definition for: " + objType);
            return;
        }

        Fixture obj = Fixture.PlaceInstance(FixturePrototypes [objType], tile);

        if (obj == null)
        {
            Debug.LogError("World:PlaceInstance returned a null object");
            return;
        }
        Fixtures.Add(obj);
        InvalidateTileGraph();
        if (cbFixtureCreated != null)
        {
            cbFixtureCreated(obj);
        }
    }
Esempio n. 6
0
        public void AddFixture(Item item)
        {
            Fixtures ??= new List <Item>();

            Fixtures.Add(item);
        }
Esempio n. 7
0
 public HolidayScheduleTable()
 {
     driver = Fixtures.GetWebDriver();
 }
 public FakeDispatcherEvent FakeDispatcherEvent()
 {
     return(Fixtures.IntegrationEvent <FakeDispatcherEvent>(FakeDispatcherCommand(), e => { }));
 }
Esempio n. 9
0
        /// <summary>
        /// Sets up the form
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //setup for testing
            CoreExtensions.Host.InitializeService();
            //get the test suite
            TestSuite suite = TestUtility.GetTestSuite(Constants.DefaultWebTestAssembly);

            //get dictionaries for forms and querying
            foreach (TestMethod tm in suite.GetMethods())
            {
                Methods.Add(tm.TestName.FullName, tm);
            }
            foreach (TestFixture tf in suite.GetFixtures())
            {
                Fixtures.Add(tf.ClassName, tf);
            }
            foreach (TestEnvironment t in EnvironmentProvider.GetEnvironments().OrderBy(a => a.Name))
            {
                Environments.Add(t.ID, t);
            }
            foreach (TestSystem tsys in SystemProvider.GetSystems().OrderBy(a => a.Name))
            {
                Systems.Add(tsys.ID, tsys);
            }
            foreach (TestSite ts in SiteProvider.GetEnabledSites().OrderBy(a => a.SystemID).ThenBy(a => a.Name))
            {
                try {
                    Sites.Add(ts.ID, ts);
                } catch (ArgumentException aex) {
                    throw new ArgumentException(string.Format("This key has already been added: {0}-{1}", ts.SystemID, ts.Name));
                }
            }

            ltlResults.Text = string.Empty;             //reset output
            ltlError.Text   = string.Empty;
            ltlLog.Text     = string.Empty;

            if (!IsPostBack)               //setup form
            {
                foreach (KeyValuePair <string, TestFixture> kvp in Fixtures)
                {
                    ListItem li = new ListItem(TestUtility.GetClassName(kvp.Value.ClassName), kvp.Value.TestName.FullName);
                    cblTests.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestEnvironment> ekvp in Environments)
                {
                    ListItem li = new ListItem(ekvp.Value.Name, ekvp.Key.ToString());
                    cblEnv.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestSystem> sykvp in Systems)
                {
                    ListItem li = new ListItem(sykvp.Value.Name, sykvp.Value.Name);
                    cblSystems.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestSite> skvp in Sites)
                {
                    ListItem li = new ListItem(string.Format("{1}<span class='systemName'>{0}</span>", Systems[skvp.Value.SystemID].Name, skvp.Value.Name), skvp.Key.ToString());
                    li.Attributes.Add("class", Systems[skvp.Value.SystemID].Name);
                    cblSites.Items.Add(li);
                }
            }
            else
            {
                foreach (ListItem li in cblSites.Items)                   //css classes get lost on postback
                {
                    li.Attributes.Add("class", Systems[Sites[int.Parse(li.Value)].SystemID].Name);
                }
            }
        }
        public async Task QueryWithArguments(int?id, string itemSubType, int?price, int expected)
        {
            var queryArgs = $"id: {id}";

            if (!(itemSubType is null))
            {
                queryArgs += $", itemSubType: {itemSubType}";
            }

            if (!(price is null))
            {
                queryArgs += $", maximumPrice: {price}";
            }
            var query       = $@"query {{
                products({queryArgs}) {{
                    sellerAgentAddress
                    sellerAvatarAddress
                    price
                    itemUsable {{
                        itemId
                        itemType
                        itemSubType
                    }}
                    costume {{
                        itemId
                        itemType
                        itemSubType
                    }}
                }}
            }}";
            var queryResult = await ExecuteQueryAsync <ShopStateType>(query, source : Fixtures.ShopStateFX());

            var products = queryResult.Data.As <Dictionary <string, object> >()["products"].As <List <object> >();

            Assert.Equal(expected, products.Count);
        }
Esempio n. 11
0
 void SignalRService_LiveMatchUpdate(object sender, Fixtures fixtures)
 {
     LiveMatches = fixtures;
     OnLiveGameRecieved();
 }
Esempio n. 12
0
 public void TearDown()
 {
     Fixtures.DeleteLocalAccount(TestAccount1.id);
     Fixtures.DeleteLocalAccount(TestAccount2.id);
     Fixtures.DeleteLocalAccountFile();
 }
Esempio n. 13
0
 public static IEnumerable <object[]> SourceFiles(string relativePath)
 {
     return(Fixtures.SourceFiles(relativePath));
 }
Esempio n. 14
0
        public async Task TestFixturesGet()
        {
            var balance = await Fixtures.Get();

            Assert.AreEqual(96094, balance.Total);
        }
Esempio n. 15
0
        public Fixtures CreateFixtureList(int playerCount)
        {
            try
            {
                var circularArray = new List <int>();

                for (int i = 0; i < playerCount; i++)
                {
                    circularArray.Add(i + 1);
                }

                // If odd amount of players add a dud player for sorting
                if (playerCount % 2 != 0)
                {
                    circularArray.Add(-1);
                }

                var fixtures = new Fixtures();
                fixtures.fixtures = new List <Fixture>();

                int gameCount = 0; // Redundant, just for testing
                int backPtr;
                int frontPtr;

                for (int i = 0; i < circularArray.Count - 1; i++)
                {
                    for (int j = 0; j < circularArray.Count / 2; j++)
                    {
                        backPtr  = 0 + j;
                        frontPtr = circularArray.Count - j - 1;

                        if (circularArray[backPtr] != -1 && circularArray[frontPtr] != -1)
                        {
                            gameCount++;

                            var newFixture = new Fixture()
                            {
                                FixtureId   = gameCount,
                                PlayerOneId = circularArray[backPtr],
                                PlayerTwoId = circularArray[frontPtr],
                            };

                            fixtures.fixtures.Add(newFixture);
                        }
                    }

                    // Loop items through circular queue
                    var copyList = new List <int>();
                    copyList.Add(circularArray[0]);
                    copyList.Add(circularArray[circularArray.Count - 1]);
                    for (int k = 2; k < circularArray.Count; k++)
                    {
                        copyList.Add(circularArray[k - 1]);
                    }

                    circularArray = copyList;
                }

                return(fixtures);
            }
            catch (Exception ex)
            {
                _logger.LogError($"{DateTime.UtcNow}: {ex.Message}");
                return(new Fixtures());
            }
        }
Esempio n. 16
0
 public void Setup()
 {
     testUserAccount   = Fixtures.SeedUser();
     client            = new Client(testUserAccount);
     myServerTransport = new ServerTransport(testUserAccount, null);
 }
Esempio n. 17
0
 public override bool IsInside(Point3D p, int height) =>
 base.IsInside(p, height) || Fixtures?.OfType <HouseTeleporter>().Any(fix => fix.Location == p) == true;
Esempio n. 18
0
 public HomePageTable()
 {
     driver = Fixtures.GetWebDriver();
 }
Esempio n. 19
0
 public void Setup()
 {
     testUserAccount = Fixtures.SeedUser();
     client          = new Client(testUserAccount);
 }
Esempio n. 20
0
        public async Task TestFixturesGet()
        {
            var account = await Fixtures.Get();

            Assert.AreEqual("acct_4yq6tcsyoged5c0ocxd", account.Id);
        }
Esempio n. 21
0
 private static HttpTest NewErrorCodeFixture(int?etcdErrorCode = null, HttpStatusCode status = HttpStatusCode.BadRequest)
 {
     return(new HttpTest()
            .RespondWithJson(status, Fixtures.CreateErrorMessage(etcdErrorCode)));
 }
Esempio n. 22
0
 public Seeder(ModelBuilder modelBuilder)
 {
     _modelBuilder = modelBuilder;
     _fixtures     = new Fixtures();
 }
Esempio n. 23
0
        /// <summary>Creates a new instance of FixturesParser </summary>
        public FixturesParser(System.String filename)
        {
            Fixtures f = new Fixtures(filename);

            weeks = f.Weeks;
        }
Esempio n. 24
0
        public void CreateFixtures_FivePlayers()
        {
            // Arrange
            Fixtures expected = new Fixtures()
            {
                fixtures = new List <Fixture>()
                {
                    new Fixture()
                    {
                        FixtureId   = 1,
                        PlayerOneId = 2,
                        PlayerTwoId = 5,
                    },
                    new Fixture()
                    {
                        FixtureId   = 2,
                        PlayerOneId = 3,
                        PlayerTwoId = 4,
                    },
                    new Fixture()
                    {
                        FixtureId   = 3,
                        PlayerOneId = 1,
                        PlayerTwoId = 5,
                    },
                    new Fixture()
                    {
                        FixtureId   = 4,
                        PlayerOneId = 2,
                        PlayerTwoId = 3,
                    },
                    new Fixture()
                    {
                        FixtureId   = 5,
                        PlayerOneId = 1,
                        PlayerTwoId = 4,
                    },
                    new Fixture()
                    {
                        FixtureId   = 6,
                        PlayerOneId = 5,
                        PlayerTwoId = 3,
                    },
                    new Fixture()
                    {
                        FixtureId   = 7,
                        PlayerOneId = 1,
                        PlayerTwoId = 3,
                    },
                    new Fixture()
                    {
                        FixtureId   = 8,
                        PlayerOneId = 4,
                        PlayerTwoId = 2,
                    },
                    new Fixture()
                    {
                        FixtureId   = 9,
                        PlayerOneId = 1,
                        PlayerTwoId = 2,
                    },
                    new Fixture()
                    {
                        FixtureId   = 10,
                        PlayerOneId = 4,
                        PlayerTwoId = 5,
                    },
                }
            };

            // Act
            Fixtures actual = _helper.CreateFixtureList(5);

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
Esempio n. 25
0
        //[Test, Category("EchoDrive")]
        //[NonParallelizable]
        public void CreateRandomLoadTest()
        {
            Random rndGen = new Random();

            LoadManager.Load load            = LoadManager.GetLoad();
            AddEditLoadPage  addEditLoadPage = new AddEditLoadPage();

            List <string> customerIds    = new List <string>(new string[] { "E49035", "E90771", "E61470", "E36516", "E101257", "E124164" });
            List <string> dollarAmounts  = new List <string>(new string[] { "0", "1", ".5", "1000000", "-3", "1000", "100" });
            List <string> equipmentTypes = new List <string>(new string[] { "van", "flatbed", "stepdeck", "reefer" });
            List <string> warehouseIds   = new List <string>(new string[] { "G12000", "G2928940", "G3317302", "G900009", "G810013",
                                                                            "G530010", "G500006", "G990007" });
            List <int> randNumDaysForward = new List <int>(new int[] { rndGen.Next(0, 15), rndGen.Next(0, 15) });
            List <int> randTimeHours      = new List <int>(new int[] { rndGen.Next(0, 23), rndGen.Next(0, 23) });
            List <int> randWeight         = new List <int>(new int[] { rndGen.Next(10000, 20000), rndGen.Next(10000, 20000) });

            randNumDaysForward.Sort();
            randTimeHours.Sort();
            randWeight.Sort();

            string randomCustomer = customerIds[rndGen.Next(customerIds.Count)];
            string today          = DateTime.Today.ToLongDateString();

            addEditLoadPage.SearchAndSelectAccountById(randomCustomer)
            .SelectMode(load.OptiMode)
            .SelectWeOwnOrCanGet(rndGen.Next(0, 5) == 1 ? "canget" : "weown")
            .SetPricing(dollarAmounts[rndGen.Next(dollarAmounts.Count)], dollarAmounts[rndGen.Next(dollarAmounts.Count)])
            .SaveLoad()
            .UpdateCargoValue(load.OptiCargoValue)
            .UpdateTenderType(load.OptiTenderType)
            .AddPickStop(warehouseIds[rndGen.Next(warehouseIds.Count)], addEditLoadPage.GetLoadDate(today, randNumDaysForward[0], randTimeHours[0]), addEditLoadPage.GetLoadDate(today, randNumDaysForward[1], randTimeHours[1]))
            .AddDropStop(warehouseIds[rndGen.Next(warehouseIds.Count)], addEditLoadPage.GetLoadDate(today, randNumDaysForward[0], randTimeHours[0]), addEditLoadPage.GetLoadDate(today, randNumDaysForward[1], randTimeHours[1]))
            .ClickElement(addEditLoadPage.ShipmentBuilderParentSubmitButton)
            .AddEquipmentWithRandomSpecialServices(equipmentTypes[rndGen.Next(0, equipmentTypes.Count)])
            .AddItem(load.OptiItemDescription, randWeight[0].ToString(), randWeight[1].ToString(), rndGen.Next(1, 3))
            .AddMoney(load.OptiMaxBuy)
            .EnterNotes(load.OptiIntNotes, load.OptiExtNotes)
            .AssignToCarrierSales(rndGen.Next(0, 5) == 1 ? "yes" : "no")
            .SubmitShipment();
            string loadIdCreated = addEditLoadPage.GetLoadIdCreated();

            addEditLoadPage.ViewShipment();
            DataRow loadGuidRow = dbAccess.GetLoadGuidFromLoadId(loadIdCreated);
            string  loadGuid    = loadGuidRow["LoadGuid"].ToString();

            StringBuilder logText  = new StringBuilder();
            string        filename = "C:\\users\\cwebb\\desktop\\loads3.csv";

            if (!File.Exists(filename))
            {
                logText.Append(loadIdCreated)
                .Append(",")
                .Append(loadGuid);
            }
            else
            {
                logText
                .Append(",")
                .Append(Environment.NewLine)
                .Append(loadIdCreated)
                .Append(",")
                .Append(loadGuid);
            }
            File.AppendAllText(filename, logText.ToString());
            RequestManager rm = Fixtures.GetRequestManager();

            rm.InitializeLoadByGuid(loadGuid);
        }
Esempio n. 26
0
        public void TestSchemaDeserializationWorksCorrectly()
        {
            var schema = JSON.Deserialize <ResourceListing>(Fixtures.CreateResourceListingJson().Result);

            schema.Should().NotBeNull("because the deserializer should throw exceptions instead of produce a null base object");

            schema.ApiVersion.Should().Be(ResourceListingVersion12.ApiVersion);
            schema.SwaggerVersion.Should().Be(SwaggerVersion.Version12);

            schema.Info.Should().NotBeNull();
            schema.Info.Title.Should().Be(ResourceListingVersion12.Info_Title);
            schema.Info.Description.Should().Be(ResourceListingVersion12.Info_Description);
            schema.Info.TermsOfServiceUrl.Should().Be(ResourceListingVersion12.Url_TermsOfServiceUrl);
            schema.Info.Contact.Should().Be(ResourceListingVersion12.Info_Contact);
            schema.Info.License.Should().Be(ResourceListingVersion12.Info_License);
            schema.Info.LicenseUrl.Should().Be(ResourceListingVersion12.Url_LicenseUrl);

            schema.Authorizations.Should().NotBeNull().And.HaveCount(1).And.ContainKey(ResourceListingVersion12.Authorization_Type_OAuth2);
            var oauth2 = schema.Authorizations[ResourceListingVersion12.Authorization_Type_OAuth2];

            oauth2.Should().NotBeNull();
            oauth2.AuthorizationType.Should().Be(ResourceListingVersion12.Authorization_Type_OAuth2);
            oauth2.KeyName.Should().BeNullOrEmpty();
            oauth2.PassAs.Should().BeNullOrEmpty();
            // Authorization Scopes
            oauth2.AuthorizationScopes.Should().HaveCount(2);
            oauth2.AuthorizationScopes[0].Name.Should().Be(ResourceListingVersion12.Scope_Email);
            oauth2.AuthorizationScopes[0].Description.Should().Be(ResourceListingVersion12.Scope_Email_Description);
            oauth2.AuthorizationScopes[1].Name.Should().Be(ResourceListingVersion12.Scope_Pets);
            oauth2.AuthorizationScopes[1].Description.Should().Be(ResourceListingVersion12.Scope_Pets_Description);
            // Grant Types
            oauth2.GrantTypes.Should().NotBeNull();
            oauth2.GrantTypes.Implicit.Should().NotBeNull();
            oauth2.GrantTypes.Implicit.LoginEndpoint.Should().NotBeNull();
            oauth2.GrantTypes.Implicit.LoginEndpoint.UrlAsUri().Should().NotBeNull().And.Be(new Uri(ResourceListingVersion12.Url_LoginEndpoint));
            oauth2.GrantTypes.AuthorizationCode.Should().NotBeNull();
            var tre = oauth2.GrantTypes.AuthorizationCode.TokenRequestEndpoint;
            var te  = oauth2.GrantTypes.AuthorizationCode.TokenEndpoint;

            tre.Should().NotBeNull();
            tre.ClientIdName.Should().NotBeNullOrEmpty().And.Be(ResourceListingVersion12.TokenRequestEndpoint_ClientIdName);
            tre.ClientSecretName.Should().NotBeNullOrEmpty().And.Be(ResourceListingVersion12.TokenRequestEndpoint_ClientSecretName);
            tre.UrlAsUri().Should().NotBeNull().And.Be(new Uri(ResourceListingVersion12.Url_TokenRequestEndpoint));
            te.Should().NotBeNull();
            te.TokenName.Should().NotBeNullOrEmpty().And.Be(ResourceListingVersion12.TokenEndpoint_TokenName);
            te.UrlAsUri().Should().NotBeNull().And.Be(new Uri(ResourceListingVersion12.Url_TokenEndpoint));

            // Apis
            var expectedApis = new[]
            {
                KvPair.Of(ResourceListingVersion12.Apis_Pet_Path, ResourceListingVersion12.Apis_Pet_Description),
                KvPair.Of(ResourceListingVersion12.Apis_User_Path, ResourceListingVersion12.Apis_User_Description),
                KvPair.Of(ResourceListingVersion12.Apis_Store_Path, ResourceListingVersion12.Apis_Store_Description)
            };

            schema.Apis.Should().HaveCount(expectedApis.Length);
            for (var i = 0; i < expectedApis.Length; i++)
            {
                schema.Apis[i].Path.Should().NotBeNullOrWhiteSpace().And.Be(expectedApis[i].Key);
                schema.Apis[i].Description.Should().NotBeNullOrWhiteSpace().And.Be(expectedApis[i].Value);
            }
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            var database             = Database.OpenNamedConnection("main-database");
            List <SportMatch> matchs = database.SportMatch.All().ToList <SportMatch>();

            //foreach (var album in albums) { Console.WriteLine(album.Title); }
            var maxDate = matchs.Max(m => m.Date);
            var minDate = matchs.Min(m => m.Date);

            for (int year = maxDate.Year; year >= minDate.Year; year--)
            {
                System.Threading.Thread.Sleep(2000);

                string url = "https://api.football-data.org/v1/competitions/?season=" + year;

                string json = MakeWebRequest(url);
                if (json == null)
                {
                    break;
                }


                List <Competition> competitions = JsonConvert.DeserializeObject <List <Competition> >(json);

                foreach (var comp in competitions.Where(c => mappings.ContainsKey(c.league)))
                {
                    System.Threading.Thread.Sleep(2000);

                    if (comp._links?.fixtures?.href != null)
                    {
                        json = MakeWebRequest(comp._links.fixtures.href);

                        if (json == null)
                        {
                            break;
                        }

                        Fixtures fixtures = JsonConvert.DeserializeObject <Fixtures>(json);
                        //Console.WriteLine("{0}-{1}-{2}", comp.caption, comp._links.fixtures.href, "OK");

                        foreach (var fix in fixtures.fixtures)
                        {
                            if (fix?.date != null)
                            {
                                mappings.TryGetValue(comp.league, out string dbCompetitionName);

                                if (matchs.Any(m => m.Date.Date == fix.date.Date && m.Competition == dbCompetitionName))
                                {
                                    var match = matchs.Where(mat => IsSameMatch(mat, fix, dbCompetitionName)).FirstOrDefault();
                                    if (match != null)
                                    {
                                        Console.WriteLine("update match");
                                    }
                                }

                                //Console.WriteLine("{0}-{1}-{2}-{3}-{4}", fix.date, fix.result, fix.homeTeamName, fix.awayTeamName, "OK");
                            }
                            else
                            {
                                Console.WriteLine("{0}-{1}", "fix", "NOLINK");
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("{0}-{1}", comp.caption, "NOLINK");
                    }
                }
            }

            Console.WriteLine("goodbye");
            Console.ReadKey();
        }
        public ActionResult GenerateFixtures(int?groupid)
        {
            Groups group = unitOfWork.GroupRepository.GetByID((int)groupid);

            if (group == null)
            {
                AddApplicationMessage("Skupina s tímto ID neexistuje", MessageSeverity.Danger);
                return(RedirectToAction("Index", "Competitions"));
            }

            int fixexist = unitOfWork.FixtureRepository.Get(filter: f => f.Group == groupid).Count();

            if (fixexist > 0)
            {
                AddApplicationMessage("Rozlosování pro tuto skupinu již existuje", Models.MessageSeverity.Danger);
                return(RedirectToAction("Admin", "Group", new { groupid = groupid }));
            }

            var teams = unitOfWork.TeamRepository.GetTeamsByGroup((int)groupid).ToList();
            // Random poradi tymu pro rozlosovani
            int    n   = teams.Count;
            Random rng = new Random();

            while (n > 1)
            {
                n--;
                int   k     = rng.Next(n + 1);
                Teams value = teams[k];
                teams[k] = teams[n];
                teams[n] = value;
            }

            if (teams.Count % 2 != 0)
            {
                var evenTeam = new Teams()
                {
                    ID = 0
                };
                teams.Add(evenTeam);
            }
            var games        = ListMatches(teams);
            int currentRound = 1;

            foreach (var round in games)
            {
                foreach (var game in round)
                {
                    if (game.Item1.ID == 0 || game.Item2.ID == 0)
                    {
                        continue;
                    }

                    Fixtures fixture = new Fixtures()
                    {
                        Team1 = game.Item1.ID,
                        Team2 = game.Item2.ID,
                        Round = currentRound,
                        Group = (int)groupid
                    };
                    unitOfWork.FixtureRepository.Insert(fixture);
                }
                currentRound++;
            }
            unitOfWork.Save();
            AddApplicationMessage("Rozlosování skupiny " + group.Name + " bylo provedeno", MessageSeverity.Success);

            return(RedirectToAction("Admin", "Group", new { groupid = groupid }));
        }
Esempio n. 29
0
 public Database()
 {
     _fixtures = new Fixtures();
 }
 public TenderHoursTable()
 {
     driver = Fixtures.GetWebDriver();
 }