public void PullTests()
        {
            DepletableBag <int>    bag        = new DepletableBag <int>(sampleList);
            Dictionary <int, bool> dictionary = new Dictionary <int, bool>();

            for (int i = 0; i < sampleList.Count; ++i)
            {
                dictionary.Add(i, false);
            }

            while (bag.Count > 0)
            {
                dictionary[bag.PopNext()] = true;
            }

            for (int i = 0; i < sampleList.Count; ++i)
            {
                Assert.IsTrue(dictionary[i + 1]);
            }

            for (int i = 0; i < 100; ++i)
            {
                if (i >= sampleList.Count)
                {
                    Assert.AreEqual(default(int), bag.PopNext());
                }
            }
        }
        public void PullAutoResetTests()
        {
            DepletableBag <int> bag = new DepletableBag <int>(sampleList);

            bag.AutoRefill = true;

            for (int i = 0; i < 100; ++i)
            {
                Assert.AreNotEqual(default(int), bag.PopNext());
            }
        }
        public void PsEmptyTests()
        {
            DepletableBag <int> bag = new DepletableBag <int>(sampleList);

            Assert.IsFalse(bag.Count <= 0);

            for (int i = 0; i < sampleList.Count - 1; ++i)
            {
                bag.PopNext();
                Assert.IsFalse(bag.Count <= 0);
            }

            bag.PopNext();
            Assert.IsTrue(bag.Count <= 0);
        }
示例#4
0
        public NotificationServer(
            IHubContext <OverlayHub> overlayHubContext,
            IHubContext <TTSMarqueeHub> ttsMarqueeHubContext,
            IWebHostEnvironment env)
        {
            _overlayHubContext    = overlayHubContext;
            _ttsMarqueeHubContext = ttsMarqueeHubContext;

            imagePath = Path.Combine(env.WebRootPath, "Assets", "Images");

            imageURLs = new DepletableBag <string>()
            {
                AutoRefill = true
            };

            foreach (string imagePath in Directory.GetFiles(imagePath))
            {
                string url = $"{ASSET_URL}/{Path.GetFileName(imagePath)}";
                imageURLs.Add(url);
            }
        }
        public void Initialize(double taskGuessRate)
        {
            trial        = 0;
            repetitions  = 0;
            correctCount = 0;

            stepBag = new DepletableBag <ConstantStimSet>()
            {
                AutoRefill = false
            };

            int dim1Limit = StimDimensions.GetSteps(0);
            int dim2Limit = StimDimensions.GetSteps(1);
            int dim3Limit = StimDimensions.GetSteps(2);
            int dim4Limit = StimDimensions.GetSteps(3);

            for (int dim1 = 0; dim1 < dim1Limit; dim1++)
            {
                for (int dim2 = 0; dim2 < dim2Limit; dim2++)
                {
                    for (int dim3 = 0; dim3 < dim3Limit; dim3++)
                    {
                        for (int dim4 = 0; dim4 < dim4Limit; dim4++)
                        {
                            //One copy for each track
                            for (int track = 0; track < Tracks; track++)
                            {
                                stepBag.Add(new ConstantStimSet(dim1, dim2, dim3, dim4));
                            }
                        }
                    }
                }
            }

            this.taskGuessRate = taskGuessRate;
        }