/// <summary> /// Setups this instance. /// </summary> public override void Setup() { base.Setup(); BenchmarkDotNet.Loggers.ConsoleLogger.Default.WriteLine(BenchmarkDotNet.Loggers.LogKind.Info, $"Collection Count={this.CollectionCount}."); this.personFixedCollection = new PersonCollection <PersonFixed>(); this.personFixedCollection.AddRange(RandomData.GeneratePersonCollection <PersonFixed>(this.CollectionCount)); this.personProperCollection = new PersonCollection <PersonProper>(); this.personProperCollection.AddRange(RandomData.GeneratePersonCollection <PersonProper>(this.CollectionCount)); this.personProperDictionary = this.personProperCollection.ToDictionary(p => p.Id); this.testEmail = this.personProperCollection[RandomData.GenerateInteger(0, this.CollectionCount - 1)].Email; this.sortablePersonProperCollection = new PersonCollection <PersonProper>(this.personProperCollection); this.personProperArrayFull = this.personProperCollection.ToArray(); this.personProperArrayHalf = this.personProperCollection.Take(CollectionCount / 2).ToArray(); this.personProperListHalf = this.personProperCollection.Take(CollectionCount / 2).ToList(); this.byteArray = RandomData.GenerateByteArray(CollectionCount / 2); this.coordinateArray = RandomData.GenerateCoordinateCollection <CoordinateProper>(CollectionCount).ToArray(); this.delimitedString = this.coordinateArray.ToDelimitedString(); }
public void GenerateIntegerTest() { var intValue = RandomData.GenerateInteger(0, 1000); Assert.IsTrue(intValue >= 0); Assert.IsTrue(intValue <= 1000); }
public void PickRandom02() { var people = new ArraySegment <PersonProper>(base.PersonProperArrayFull); var result = people.Slice(RandomData.GenerateInteger(0, people.Count - 1)); base.Consumer.Consume(result); }
public void PickRandom02() { var people = new ArraySegment <PersonProper>(base.GetPersonProperArray(Tristate.False, CollectionSize.Half)); var result = people.Slice(RandomData.GenerateInteger(0, people.Count - 1)); base.Consumer.Consume(result); }
public void CloneArrayTest() { var count = RandomData.GenerateInteger(10, 500); var people = RandomData.GeneratePersonCollection <PersonProper>(count).ToArray(); var result = people.Clone <PersonProper>(); Assert.IsTrue(people.Count() == result.Count()); }
public void AddItemsToCacheTest() { var cache = InMemoryCache.Instance; for (var count = 0; count < TestCount; count++) { cache.AddCacheItem <int>(key: RandomData.GenerateKey(), item: RandomData.GenerateInteger(count, 1000000)); } Assert.IsTrue(cache.Count == TestCount); }
public void AddItemsToCache() { var cache = InMemoryCache.Instance; for (int i = 0; i < _testCount; i++) { cache.AddCacheItem <int>(RandomData.GenerateKey(), RandomData.GenerateInteger(i, 1000000)); } Assert.IsTrue(cache.Count == _testCount); }
public void ClearNullListTest() { var count = RandomData.GenerateInteger(10, 500); var people = RandomData.GeneratePersonCollection <PersonProper>(count); people.Add(null); Assert.IsTrue(people.ClearNulls()); Assert.IsFalse(people.ClearNulls()); Assert.IsFalse(new List <PersonProper>(10).ClearNulls()); }
/// <summary> /// Setups this instance. /// </summary> /// TODO Edit XML Comment Template for Setup public override void Setup() { base.Setup(); BenchmarkDotNet.Loggers.ConsoleLogger.Default.WriteLine(BenchmarkDotNet.Loggers.LogKind.Info, $"Collection Count={this.CollectionCount}."); this.personFixedCollection = new PersonCollection <PersonFixed>(); this.personFixedCollection.AddRange(RandomData.GeneratePersonCollection <PersonFixed>(this.CollectionCount)); this.personProperCollection = new PersonCollection <PersonProper>(); this.personProperCollection.AddRange(RandomData.GeneratePersonCollection <PersonProper>(this.CollectionCount)); this.personProperDictionary = this.personProperCollection.ToDictionary(p => p.Id); this.testEmail = this.personProperCollection[RandomData.GenerateInteger(0, this.CollectionCount - 1)].Email; this.sortablePersonProperCollection = new PersonCollection <PersonProper>(this.personProperCollection); }
public void IntToFormattedStringTest() { var testValue = RandomData.GenerateInteger(); var result = testValue.ToFormattedString(NumericFormat.Currency); PrintResult(result, nameof(NumericFormat.Currency)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.Decimal); PrintResult(result, nameof(NumericFormat.Decimal)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.Exponential); PrintResult(result, nameof(NumericFormat.Exponential)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.FixedPoint); PrintResult(result, nameof(NumericFormat.FixedPoint)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.General); PrintResult(result, nameof(NumericFormat.General)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.Hexadecimal); PrintResult(result, nameof(NumericFormat.Hexadecimal)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.Number); PrintResult(result, nameof(NumericFormat.Number)); Assert.IsTrue(result.Length > 5); result = testValue.ToFormattedString(NumericFormat.Percent); PrintResult(result, nameof(NumericFormat.Percent)); Assert.IsTrue(result.Length > 5); Assert.ThrowsException <ArgumentInvalidException>(() => testValue.ToFormattedString(NumericFormat.RoundTrip)); }