Exemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////////////
        // Public methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region PUBLICMETHODS
        #endregion //PUBLICMETHODS

        ///////////////////////////////////////////////////////////////////////////////
        // Inherited methods                                                         //
        ///////////////////////////////////////////////////////////////////////////////
        #region OVERRIDES

        /// <summary>
        /// Overridden. This method is used to initialize elements that are not
        /// initialized in the designer.
        /// </summary>
        protected override void InitializeCustomElements()
        {
            base.InitializeCustomElements();
            this.exportOptions = new ExportOptions();
            PopulateSubjectTreeView(this.trvSubjects);

            DataTable table = Document.ActiveDocument.DocDataSet.TrialsAdapter.GetData();

            StatisticsModule.FillTreeView(this.trvTrialsDefault, table);
        }
Exemplo n.º 2
0
        public EtcdClient(Uri etcdLocation)
        {
            var uriBuilder = new UriBuilder(etcdLocation)
            {
                Path = ""
            };
            var root = uriBuilder.Uri;
            _keysRoot = root.AppendPath("v2").AppendPath("keys");
            _client = new RestClient(root.ToString());

            Statistics = new StatisticsModule(root, _client);
        }
Exemplo n.º 3
0
 public AeroDaltonImperial()
     : base()
 {
     this.defaultDistance      = 200;
     this.maximumDistance      = 300;
     this.boundarySafeZone     = 40;
     this.moveTargetSampleSize = 12;
     this.enemies      = new Dictionary <string, EnemyData>();
     this.enemyBullets = new List <WaveBullet>();
     this.statistics   = new StatisticsModule();
     this.randomizer   = new Random();
 }
Exemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////////////
        // Eventhandler                                                              //
        ///////////////////////////////////////////////////////////////////////////////
        #region EVENTHANDLER

        /// <summary>
        /// The <see cref="Control.Click"/> event handler for the
        /// <see cref="Button"/> <see cref="btnOK"/>.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">An empty <see cref="EventArgs"/></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.chbGaze.Checked)
            {
                this.sfdExport.Title = "Please specify gaze fixations export file name ...";
                if (this.sfdExport.ShowDialog() == DialogResult.OK)
                {
                    this.exportOptions.GazeFileName = this.sfdExport.FileName;
                    this.exportOptions.ExportGaze   = true;
                }
            }

            if (this.chbMouse.Checked)
            {
                this.sfdExport.Title = "Please specify mouse fixations export file name ...";
                if (this.sfdExport.ShowDialog() == DialogResult.OK)
                {
                    this.exportOptions.MouseFileName = this.sfdExport.FileName;
                    this.exportOptions.ExportMouse   = true;
                }
            }

            if (this.chbSubjectDetail.Checked)
            {
                this.exportOptions.ExportSubjectDetails = true;
            }

            if (this.chbTrialDetail.Checked)
            {
                this.exportOptions.ExportTrialDetails = true;
            }

            if (this.chbAOIInfo.Checked)
            {
                this.exportOptions.ExportAOIDetails = true;
            }

            if (this.rdbFixations.Checked)
            {
                this.exportOptions.ExportFixations = true;
            }
            else
            {
                this.exportOptions.ExportFixations = false;
            }

            this.exportOptions.CheckedSubjects = GetCheckedSubjects(this.trvSubjects);
            this.exportOptions.CheckedTrialIDs = StatisticsModule.GetSelectedTrials(this.trvTrialsDefault);
        }
Exemplo n.º 5
0
        public EtcdClient(Uri etcdLocation)
        {
            var uriBuilder = new UriBuilder(etcdLocation)
            {
                Path = ""
            };

            var path = etcdLocation.LocalPath.StartsWith("/")
                ? etcdLocation.LocalPath.Substring(1)
                : etcdLocation.LocalPath;

            var root = uriBuilder.Uri;
            _keysRoot = root.AppendPath(path).AppendPath("v2").AppendPath("keys");
            _client = new RestClient(root.ToString());

            Statistics = new StatisticsModule(root, _client);
            Machine = new MachineModule(root);
            Members = new MembersModule(root, _client);
        }
Exemplo n.º 6
0
        protected override void OnMinesweeperChanged()
        {
            if (this.gameStarted)
            {
                this.ResetGame();
            }

            var gameStatistics = StatisticsModule.Create();
            var minesweeper    = this.Minesweeper;

            this.Settings.LastBoardSize = new BoardSize(minesweeper.Tiles.Width, minesweeper.Tiles.Height, minesweeper.MineCount);

            gameStatistics[Statistic.BoardSize] = new BoardSize(minesweeper.Tiles.Width, minesweeper.Tiles.Height, minesweeper.MineCount);

            this.DisplayViewModel.Minesweeper   = minesweeper;
            this.TileBoardViewModel.Minesweeper = minesweeper;

            this.GameStatistics = gameStatistics;
            this.DisplayViewModel.GameStatistics   = gameStatistics;
            this.TileBoardViewModel.GameStatistics = gameStatistics;
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var callback = Runner.createConsoleReporter(100);
            var property = Property.Default.Callback(callback);

            //A simple example
            property
            .Add(Syntax.Prop.ForAll(Arb.Array(Arb.Int).NonNull, xs => xs.Reverse().Reverse().SequenceEqual(xs)))
            .Run("RevRev");

            property
            .Add(Syntax.Prop.ForAll(Arb.Array(Arb.Int).NonNull, xs => xs.Reverse().SequenceEqual(xs)))
            .Run("RevId");

            //--------Properties--------------
            property
            .Add(Syntax.Prop.ForAll(Arb.Array(Arb.Single).NonNull, xs => xs.Reverse().Reverse().SequenceEqual(xs)))
            .Run("RevRevFloat");

            //conditional properties
            property
            .Add(Syntax.Prop.ForAll(Arb.Int, Arb.Array(Arb.Int).NonNull, (x, xs) =>
                                    new Lazy <bool>(() => xs.Insert(x).IsOrdered())
                                    .When(xs.IsOrdered())))
            .Run("Insert");

            property
            .Add(Syntax.Prop.ForAll(Arb.Int, a =>
                                    new Lazy <bool>(() => 1 / a == 1 / a)
                                    .When(a != 0)))
            .Run("DivByZero");

            //counting trivial cases
            property
            .Add(Syntax.Prop.ForAll(Arb.Int, Arb.Array(Arb.Int).NonNull, (x, xs) =>
                                    new Lazy <bool>(() => xs.Insert(x).IsOrdered())
                                    .When(xs.IsOrdered())
                                    .Classify(xs.Count() == 0, "trivial")))
            .Run("InsertTrivial");

            //classifying test values
            property
            .Add(Syntax.Prop.ForAll(Arb.Int, Arb.Array(Arb.Int).NonNull, (x, xs) =>
                                    new Lazy <bool>(() => xs.Insert(x).IsOrdered())
                                    .When(xs.IsOrdered())
                                    .Classify(new int[] { x }.Concat(xs).IsOrdered(), "at-head")
                                    .Classify(xs.Concat(new int[] { x }).IsOrdered(), "at-tail")))
            .Run("InsertClassify");

            //collecting data values
            property
            .Add(Syntax.Prop.ForAll(Arb.Int, Arb.Array(Arb.Int).NonNull, (x, xs) =>
                                    new Lazy <bool>(() => xs.Insert(x).IsOrdered())
                                    .When(xs.IsOrdered())
                                    .Collect("length " + xs.Count().ToString())))
            .Run("InsertCollect");

            //combining observations
            property
            .Add(Syntax.Prop.ForAll(Arb.Int, Arb.Array(Arb.Int).NonNull, (x, xs) =>
                                    new Lazy <bool>(() => xs.Insert(x).IsOrdered())
                                    .When(xs.IsOrdered())
                                    .Classify(new int[] { x }.Concat(xs).IsOrdered(), "at-head")
                                    .Classify(xs.Concat(new int[] { x }).IsOrdered(), "at-tail")
                                    .Collect("length " + xs.Count().ToString())))
            .Run("InsertCombined");

            //---labelling sub properties-----
            //hmm. Cannot express result = m + n once this way.
            property
            .Add(Syntax.Prop.ForAll(Arb.Int, Arb.Int, (m, n) =>
                                    (m + n >= m).Label("result > #1") //maybe add overload with label to ForAll?
                                    .And(() => (m + n >= n).Label("result > #2"))
                                    .And(() => (m + n < m + n).Label("result not sum"))))
            .Run("ComplexProp");

            property
            .Add(Syntax.Prop.ForAll(Arb.Int, x =>
                                    false.Label("Always false")
                                    .And(() => Math.Abs(x) - x == 0))) //actually, And should start a new property, not just a new assertion...
            .Run("Label");

            //rest seem hard to express without real "And" and "Or" support

            //-------Test data generators-----------
            //can't be made generic, only in separate method?
            Func <int[], Gen <int> > chooseFromList = xs =>
                                                      Gen.Choose(StatisticsModule.UniformDiscrete(0, xs.Length - 1))
                                                      .Select(i => xs[i]);

            var chooseBool = Persimmon.Dried.Ext.Gen.OneOf(Gen.Constant(true), Gen.Constant(false));

            //no tuples in C# until BCL 4.0...can we do better now?
            var chooseBool2 = Persimmon.Dried.Ext.Gen.Frequency(
                Tuple.Create(2, Gen.Constant(true)),
                Tuple.Create(1, Gen.Constant(false)));

            //the size of test data : see matrix method

            //generating recursive data types: not so common in C#?

            var config = new Configuration {
                Callback = callback
            };

            // generating functions:
            Syntax.Prop.ForAll(Arb.Func(CoArb.Int, Arb.Int), Arb.Func(CoArb.Int, Arb.Int), Arb.ICollection(Arb.Int).NonNull,
                               (f, g, a) => {
                var l1 = a.Select(x => f(g(x)));
                var l2 = a.Select(g).Select(f);
                return(l1.SequenceEqual(l2));
            }).Run(config);

            //generators support select, selectmany and where
            var gen = Arb.Int.Gen
                      .Where(x => x > 5)
                      .SelectMany(x => Gen.Choose(StatisticsModule.UniformDiscrete(5, 10)
                                                  .Select(y => new { Fst = x, Snd = y })));

            Syntax.Prop.ForAll(MyLongArb, l => l + 1 > l)
            .Run(config);

            Syntax.Prop.ForAll(Arb.String, s => true)
            .Run(new Configuration {
                Name = "Configuration Demo", MaxSize = 500, Callback = config.Callback
            });

            Syntax.Prop.ForAll(Arb.IEnumerable(Arb.Int).NonNull, Arb.IEnumerable(Arb.Int).NonNull,
                               (a, b) => a.Except(b).Count() <= a.Count())
            .Run(config);

            Console.ReadKey();
        }