Exemplo n.º 1
0
        public void RangeOrNotInRange()
        {
            int year = SampleMethod.GetVehicleYear();

            Assert.InRange(year, 2000, 2021);
            Assert.NotInRange(year, 1995, 1999);
        }
Exemplo n.º 2
0
        public void StartWithOrEndWith()
        {
            string brand = SampleMethod.GetBrand();

            Assert.StartsWith("Volks", brand);
            Assert.EndsWith("agen", brand);
        }
Exemplo n.º 3
0
        public void EmptyOrNotEmpty()
        {
            List <string> models = SampleMethod.GetModels();

            Assert.NotEmpty(models);
            Assert.Empty(new List <int>());
        }
Exemplo n.º 4
0
        public void TrueOrFalse()
        {
            string brand = SampleMethod.GetBrand();

            Assert.True(brand.GetType() == typeof(string));
            Assert.False(brand.GetType() == typeof(int));
        }
Exemplo n.º 5
0
        public void MatchOrDoesNotMatch()
        {
            string brand = SampleMethod.GetBrand();

            Assert.Matches("^Volk", brand);
            Assert.DoesNotMatch("dog$", brand);
        }
Exemplo n.º 6
0
        public void EqualOrNotEqual()
        {
            string brand = SampleMethod.GetBrand();

            Assert.Equal("Volkswagen", brand);
            Assert.NotEqual("Scoda", brand);
        }
Exemplo n.º 7
0
        public void NullOrNotNull()
        {
            List <string> models = SampleMethod.GetModels();

            Assert.NotNull(models);
            Assert.Null(null);
        }
Exemplo n.º 8
0
        public void ContainOrDoesNotContains()
        {
            string        brand  = SampleMethod.GetBrand();
            List <string> models = SampleMethod.GetModels();

            Assert.Contains("agen", brand);
            Assert.DoesNotContain("skoda", brand);

            Assert.Contains(models, item => item.Equals("Golf", StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 9
0
        public List <int> PrepareSampleSpace(int spacesize, SampleMethod samplemethod)
        {
            switch (samplemethod)
            {
            case SampleMethod.Descending:
                return(Enumerable.Range(0, spacesize).Reverse().ToList());

            case SampleMethod.UniformWithoutReplacement:
                return(rng.Permutation(spacesize));

            default:
                return(Enumerable.Range(0, spacesize).ToList());
            }
        }
Exemplo n.º 10
0
        public List <int> PrepareSampleSpace(List <int> space, SampleMethod samplemethod)
        {
            switch (samplemethod)
            {
            case SampleMethod.Descending:
                space.Reverse();
                break;

            case SampleMethod.UniformWithoutReplacement:
                space = rng.Shuffle(space);
                break;

            default:
                break;
            }
            return(space);
        }
Exemplo n.º 11
0
        public void Single()
        {
            List <string> models = SampleMethod.GetSingleModels();

            Assert.Single(models);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractRandomNumberGenerator"/> class.
 /// </summary>
 /// <param name="threadSafe">if set to <c>true</c> , the class is thread safe.</param>
 /// <remarks>Thread safe instances are two and half times slower than non-thread
 /// safe classes.</remarks>
 protected AbstractRandomNumberGenerator(bool threadSafe)
 {
     _sampleMethod = threadSafe ? (SampleMethod)ThreadSafeSample : DoSample;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractRandomNumberGenerator"/> class.
 /// </summary>
 /// <param name="threadSafe">if set to <c>true</c> , the class is thread safe.</param>
 /// <remarks>Thread safe instances are two and half times slower than non-thread
 /// safe classes.</remarks>
 protected AbstractRandomNumberGenerator(bool threadSafe)
 {
     _sampleMethod = threadSafe ? (SampleMethod)ThreadSafeSample : DoSample;
 }
Exemplo n.º 14
0
        public void UpdateSampleSpace(SampleMethod condsamplemethod, List <string> blockparams, SampleMethod blocksamplemethod)
        {
            this.condsamplemethod  = condsamplemethod;
            this.blocksamplemethod = blocksamplemethod;
            finalblockcond.Clear();
            blocksamplespace.Clear();
            condsamplespaces.Clear();
            blockrepeat.Clear();
            condsamplespacerepeat.Clear();
            condrepeat.Clear();
            blocksampleidx = -1;
            condsampleidx  = -1;
            blockidx       = -1;
            condidx        = -1;
            nblock         = 0;

            if (ncond <= 0)
            {
                return;
            }

            var vbp = cond.Keys.Intersect(blockparams).ToList();
            Dictionary <string, List <object> > blockorthofactorlevel = null, blockcond = new Dictionary <string, List <object> >();
            int bn = 0;

            if (vbp.Count > 0)
            {
                var bpfl = new Dictionary <string, List <object> >();
                foreach (var p in vbp)
                {
                    bpfl[p] = cond[p].Distinct().ToList();
                }
                blockorthofactorlevel = bpfl.OrthoCondOfFactorLevel();
                bn = blockorthofactorlevel.Values.First().Count;
            }
            if (bn < 2)
            {
                blocksamplespace.Add(0);
                condsamplespaces.Add(PrepareSampleSpace(ncond, condsamplemethod));
                ResetCondSampleSpace(0);
            }
            else
            {
                foreach (var bp in blockorthofactorlevel.Keys)
                {
                    blockcond[bp] = new List <object>();
                }
                for (var bi = 0; bi < bn; bi++)
                {
                    var l = Enumerable.Repeat(true, ncond).ToList();
                    foreach (var f in blockorthofactorlevel.Keys)
                    {
                        var fl = blockorthofactorlevel[f][bi];
                        l = cond[f].Select((v, i) => Equals(v, fl) & l[i]).ToList();
                    }
                    var space = Enumerable.Range(0, ncond).Where(i => l[i] == true).ToList();
                    if (space.Count > 0)
                    {
                        condsamplespaces.Add(PrepareSampleSpace(space, condsamplemethod));
                        ResetCondSampleSpace(condsamplespaces.Count - 1);
                        foreach (var bp in blockorthofactorlevel.Keys)
                        {
                            blockcond[bp].Add(blockorthofactorlevel[bp][bi]);
                        }
                    }
                }
                finalblockcond   = blockcond.FinalizeFactorValues();
                blocksamplespace = PrepareSampleSpace(condsamplespaces.Count, blocksamplemethod);
            }
            foreach (var i in blocksamplespace)
            {
                blockrepeat[i] = 0;
            }
            for (var i = 0; i < ncond; i++)
            {
                condrepeat[i] = 0;
            }
            nblock = blocksamplespace.Count;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractRandomNumberGenerator"/> class.
 /// </summary>
 /// <param name="threadSafe">if set to <c>true</c> , the class is thread safe.</param>
 /// <remarks>Thread safe instances are two and half times slower than non-thread
 /// safe classes.</remarks>
 protected AbstractRandomNumberGenerator(bool threadSafe)
 {
     this._sampleMethod = threadSafe ? (SampleMethod)this.ThreadSafeSample : this.DoSample;
 }