Example #1
0
        public void TestMethod1()
        {
            SortableObservableCollection <int> list1 = new SortableObservableCollection <int>();
            var list2  = new SortableObservableCollection <int>();
            var random = new Random();
            var ready  = false;
            var thread = new Thread(() =>
            {
                for (int i = 0; i < 100000; i++)
                {
                    list2.Insert(0, random.Next());
                    while (list2.Count > 100)
                    {
                        list2.RemoveAt(list2.Count - 1);
                    }
                }
                ready = true;
            });

            thread.Start();
            for (int i = 0; i < 1000000; i++)
            {
                list1.Sync(list2);
            }
            while (!ready)
            {
                Thread.Sleep(1);
            }
            Assert.AreEqual(list1.Count, list2.Count);
            for (int i = 0; i < list1.Count; i++)
            {
                Assert.AreEqual(list1[i], list2[i]);
            }
        }
Example #2
0
        public void GenerateTickets()
        {
            MainWindow window = new MainWindow();
            var        random = new Random();

            window.generator = new KenoLoader();
            var generator = (KenoLoader)window.generator;

            generator.Path = "test.xml";
            generator.Load();
            var player = new Player()
            {
                Name = "Loaded4", NumberOfTickets = 28, Stake = 1, Money = 100, System = 6, HotNumbers = 7, ColdNumbers = 0, HotRange = 11, ColdRange = 21, StatRange = 1
            };

            for (int i = 7800; i < generator.results.Count; i++)
            {
                var numbers = window.generator.Generate();
                foreach (var numberStat in window.NumbersStatistic)
                {
                    numberStat.Appear(numbers.Contains(numberStat.Number));
                }
                var tempStat = new SortableObservableCollection <NumberStat>();
                tempStat.Sync(window.NumbersStatistic);
                tempStat.Sort(x => x.TimesAppear(player.StatRange), ListSortDirection.Descending);

                window.GenerateNumbersBuyTickets(player, window.NumbersStatistic, random);
                var wonMoney = Calculate.CalculateTickets(numbers, player.Tickets);
                Console.WriteLine(wonMoney);
            }


            //foreach (var ticket in player.Tickets)
            //{
            //    foreach (var number in ticket.Numbers)
            //    {
            //        Console.Write(number + ";");
            //    }
            //    Console.WriteLine("\t" + ticket.wonNumbers + " " + ticket.wonAmount);
            //}
            Console.WriteLine();

            window.GenerateNumbersBuyTickets(player, window.NumbersStatistic, random);

            foreach (var ticket in player.Tickets)
            {
                foreach (var number in ticket.Numbers)
                {
                    Console.Write(number + " ");
                }
                Console.WriteLine();
            }
        }