public void RangeOrNotInRange() { int year = SampleMethod.GetVehicleYear(); Assert.InRange(year, 2000, 2021); Assert.NotInRange(year, 1995, 1999); }
public void StartWithOrEndWith() { string brand = SampleMethod.GetBrand(); Assert.StartsWith("Volks", brand); Assert.EndsWith("agen", brand); }
public void EmptyOrNotEmpty() { List <string> models = SampleMethod.GetModels(); Assert.NotEmpty(models); Assert.Empty(new List <int>()); }
public void TrueOrFalse() { string brand = SampleMethod.GetBrand(); Assert.True(brand.GetType() == typeof(string)); Assert.False(brand.GetType() == typeof(int)); }
public void MatchOrDoesNotMatch() { string brand = SampleMethod.GetBrand(); Assert.Matches("^Volk", brand); Assert.DoesNotMatch("dog$", brand); }
public void EqualOrNotEqual() { string brand = SampleMethod.GetBrand(); Assert.Equal("Volkswagen", brand); Assert.NotEqual("Scoda", brand); }
public void NullOrNotNull() { List <string> models = SampleMethod.GetModels(); Assert.NotNull(models); Assert.Null(null); }
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)); }
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()); } }
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); }
public void Single() { List <string> models = SampleMethod.GetSingleModels(); Assert.Single(models); }
/// <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; }
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; }