/// <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();
        }
Example #2
0
        /// <summary>
        /// Setups this instance.
        /// </summary>
        public override void Setup()
        {
            base.Setup();

            ConsoleLogger.Default.WriteLine(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.Shuffle().First().Email;

            this.sortablePersonProperCollection = new PersonCollection <PersonProper>(this.personProperCollection);

            this.personProperArrayFull = this.personProperCollection.ToArray();
            this.personProperArrayHalf = this.personProperCollection.Take((this.CollectionCount / 2).EnsureMinimumValue(2)).ToArray();

            this.personProperListHalf = this.personProperCollection.Take((this.CollectionCount / 2).EnsureMinimumValue(2)).ToList();

            this.byteArray = RandomData.GenerateByteArray((this.CollectionCount / 2).EnsureMinimumValue(2));

            this.coordinateArray = RandomData.GenerateCoordinateCollection <CoordinateProper>(this.CollectionCount).ToArray();

            this.delimitedString = this.coordinateArray.ToDelimitedString();
        }
        public void BytesToStringTest()
        {
            var bytes = RandomData.GenerateByteArray(100);

            var result = bytes.BytesToString();

            Assert.IsTrue(result.Length > 100);
        }
        public void AppendJoin()
        {
            var sb = new StringBuilder();

            sb.AppendJoin <byte>('-', RandomData.GenerateByteArray(1));

            base.Consumer.Consume(sb.ToString());
        }
        public void BytesToStringUsingSpanTest()
        {
            var bytes = RandomData.GenerateByteArray(100);

            var readOnlySpan = new ReadOnlySpan <byte>(bytes);
            var result       = readOnlySpan.BytesToString();

            Assert.IsTrue(result.Length > 100);
        }
Example #6
0
        public void AppendBytesTest()
        {
            var sb        = new StringBuilder();
            var byteArray = RandomData.GenerateByteArray(sizeInKb: 1);

            sb.AppendBytes(byteArray);

            Assert.IsTrue(sb.Length > 50);
        }
        public void BytesToStringTest()
        {
            var bytes = RandomData.GenerateByteArray(100);

            var result = bytes.BytesToString();

            Assert.IsTrue(result.Length > 20000);

            byte[] nullBytes = null;

            _ = Assert.ThrowsException <NullReferenceException>(() => nullBytes.BytesToString());
        }
        public void BytesToStringUsingSpanTest()
        {
            var bytes = RandomData.GenerateByteArray(100);

            var readOnlySpan = new ReadOnlySpan <byte>(bytes);
            var result       = readOnlySpan.BytesToString();

            Assert.IsTrue(result.Length > 20000);

            byte[] nullBytes = null;

            _ = Assert.ThrowsException <NullReferenceException>(() => nullBytes.BytesToString());
        }
        public void GenerateByteArrayTest()
        {
            var byteArray = RandomData.GenerateByteArray(.01);

            Assert.IsTrue(byteArray.Length > 0);
        }
Example #10
0
        /// <summary>
        /// Setups this instance.
        /// </summary>
        public override void Setup()
        {
            base.Setup();

            ConsoleLogger.Default.WriteLine(LogKind.Info, $"Collection Count={this.Count}.");

            this.PersonProperList = new List <PersonProper>();
            this.PersonProperList.AddRange(RandomData.GeneratePersonCollection <PersonProper>(this.Count));

            this.LoadPersonRefArray();
            this.LoadPersonValArray();

            this.PersonProperCollection = this.PersonProperList.ToCollection();

            this.PersonProperObservableList = this.PersonProperList.ToObservableList();

            this.PersonProperFastSortedList = this.PersonProperList.ToFastSortedList();

            this.PersonProperHashSet = this.PersonProperList.ToHashSet();

            this.PersonProperConcurrentHashSet = this.PersonProperHashSet.ToConcurrentHashSet();

            this.PersonProperDistinctBlockingCollection = this.PersonProperList.ToDistinctBlockingCollection(false);

            this.PersonProperDictionary = this.PersonProperList.ToDictionary(p => p.Id);

            this.PersonProperSortableList = new List <PersonProper>(this.PersonProperList);

            this.PersonProperArrayFull = this.PersonProperList.ToArray();

            this.PersonProperArrayHalf = this.PersonProperList.Take(this.Count / 2).ToArray();

            this.PersonProperListHalf = this.PersonProperList.Take(this.Count / 2).ToList();

            this.ByteArray = RandomData.GenerateByteArray(this.Count / 2);

            this.CoordinateProperArray = RandomData.GenerateCoordinateCollection <CoordinateProper>(this.Count).ToArray();

            this.CommaDelimitedString = this.CoordinateProperArray.ToDelimitedString();

            this.StringArray = RandomData.GenerateWords(this.Count, minLength: 15, maxLength: 15).ToArray();

            this.PersonRecordArray = RandomData.GeneratePersonCollection(this.Count).ToArray();

            this.PersonRecordList = RandomData.GeneratePersonCollection(this.Count);

            this.PersonProperImmutableList = this.PersonProperList.ToImmutable();

            this.PersonProperObservableCollection = this.PersonProperList.ToObservableCollection();

            this.PersonProperReadOnlyCollection = this.PersonProperList.ToReadOnlyCollection();

            this.PersonProperImmutableDictionary = this.PersonProperDictionary.ToImmutable();

            this.PersonProperLinkedList = this.PersonProperList.ToLinkedList();

            this.PersonProperConcurrentBag = new ConcurrentBag <PersonProper>(this.PersonProperList);

            this.CoordinateProperList = this.CoordinateProperArray.ToList();

            this.PersonProperConcurrentDictionary = new ConcurrentDictionary <string, PersonProper>(this.PersonProperDictionary);

            this.PersonProperBlockingCollection = this.PersonProperList.ToBlockingCollection();

            this.PersonProperDistinctConcurrentBag = this.PersonProperList.ToDistinctConcurrentBag();

            this.PersonList = RandomData.GeneratePersonCollection <Tester.Models.RefTypes.Person>(this.Count);

            this.PersonProperEnumerable = this.PersonProperList.AsEnumerable();

            this.PersonValList = RandomData.GeneratePersonCollection <Tester.Models.ValueTypes.Person>(Count);
        }