public void AppendValuesTest()
        {
            var sb     = new StringBuilder();
            var values = RandomData.GenerateCoordinateCollection <Coordinate>(count: 15);

            sb.AppendValues(", ", values, (person) =>
            {
                _ = sb.Append(person.X);
                _ = sb.Append(ControlChars.Colon);
                _ = sb.Append(person.Y);
            });

            Assert.IsTrue(sb.Length > 50);

            var pool = new StringBuilder();

            pool.AppendValues(", ", values, (person) =>
            {
                _ = pool.Append(person.X);
                _ = pool.Append(ControlChars.Colon);
                _ = pool.Append(person.Y);
            });

            Assert.IsTrue(pool.Length > 50);
        }
Esempio n. 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();
        }
        /// <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();
        }
Esempio n. 4
0
        /// <summary>
        /// Loads the coordinate array.
        /// </summary>
        protected void LoadCoordinateProperArray()
        {
            this._coordinateProperArray = RandomData.GenerateCoordinateCollection <CoordinateProper>(this.MaxCount).ToArray();
            ConsoleLogger.Default.WriteLine($"{nameof(this._coordinateProperArray)} Length = {this._coordinateProperArray.Length}.");

            this._coordinateProperArrayHalf = RandomData.GenerateCoordinateCollection <CoordinateProper>(this.MaxCount / 2).Clone <CoordinateProper[]>();
            ConsoleLogger.Default.WriteLine($"{nameof(this._coordinateProperArrayHalf)} Length = {this._coordinateProperArrayHalf.Length}.");
        }
Esempio n. 5
0
        /// <summary>
        /// Loads the coordinate array.
        /// </summary>
        protected void LoadCoordinateArray()
        {
            this._coordinateArray     = RandomData.GenerateCoordinateCollection <Tester.Models.ValueTypes.Coordinate>(this.MaxCount).ToArray();
            this._coordinateArrayHalf = RandomData.GenerateCoordinateCollection <Tester.Models.ValueTypes.Coordinate>(this.MaxCount / 2).ToArray();

            ConsoleLogger.Default.WriteLine($"{nameof(this._coordinateArray)} Count = {this._coordinateArray.Length}.");
            ConsoleLogger.Default.WriteLine($"{nameof(this._coordinateArrayHalf)} Count = {this._coordinateArrayHalf.Length}.");
        }
        public void GenerateCoordinateCollectionTest()
        {
            var coordinates = RandomData.GenerateCoordinateCollection <CoordinateProper>(Count);

            Assert.IsNotNull(coordinates);

            Assert.IsTrue(coordinates.Count() == Count);
        }
        public void HasItemsTestWithCount()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToImmutable();
            ImmutableList <Coordinate> nullCollection = null;

            Assert.IsFalse(collection.HasItems(5));

            Assert.IsFalse(nullCollection.HasItems());
        }
        public void HasItemsTest02()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToImmutableArray();
            Func <Coordinate, bool> selector = (coordinate) => coordinate.X > 0;

            Assert.IsTrue(collection.HasItems(selector));

            Assert.IsFalse(collection.HasItems(null));
        }
Esempio n. 9
0
        public void HasItemsTest()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToList().ToObservableCollection();
            ObservableCollection <Coordinate> nullCollection = null;

            Assert.IsTrue(collection.HasItems());

            Assert.IsFalse(nullCollection.HasItems());
        }
        public void DoesNotHaveItemsTest()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToList();
            List <Coordinate> nullCollection = null;

            Assert.IsFalse(collection.DoesNotHaveItems());

            Assert.IsTrue(nullCollection.DoesNotHaveItems());
        }
        public void FirstOrNullTest()
        {
            var coordinates = RandomData.GenerateCoordinateCollection <CoordinateProper>(10);
            var searchValue = coordinates.Last().X;

            //Test Finding Days of over 100
            Assert.IsNotNull(coordinates.FirstOrNull(p => p.X == searchValue));
            Assert.IsNull(coordinates.FirstOrNull(p => p.X == int.MinValue));
        }
        public void HasItemsTestWithCount()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToCollection();

            Core.Collections.Generic.Collection <Coordinate> nullCollection = null;

            Assert.IsFalse(collection.HasItems(5));

            Assert.IsFalse(nullCollection.HasItems());
        }
Esempio n. 13
0
        public void HasItemsWithFunctionTest()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToList().ToObservableCollection();
            ObservableCollection <Coordinate> nullCollection = null;

            Func <Coordinate, bool> selector = (coordinate) => coordinate.X > 0;

            Assert.IsTrue(collection.HasItems(selector));

            Assert.IsFalse(nullCollection.HasItems());
        }
        public void FirstOrNullTest()
        {
            var coordinates = RandomData.GenerateCoordinateCollection <CoordinateProper>(10).AsEnumerable();
            var searchValue = coordinates.Last().X;

            //Test Params
            _ = Assert.ThrowsException <ArgumentNullException>(() => coordinates.FirstOrNull(null));

            //Test Finding Days of over 100
            Assert.IsNotNull(coordinates.FirstOrNull(p => p.X == searchValue));
            Assert.IsNull(coordinates.FirstOrNull(p => p.X == int.MinValue));
        }
Esempio n. 15
0
        public void AppendJoinTest02()
        {
            var sb     = new StringBuilder();
            var values = RandomData.GenerateCoordinateCollection <Coordinate>(count: 15);

            sb.AppendValues(", ", values, (person) =>
            {
                sb.Append(person.X);
                sb.Append(dotNetTips.Utility.Standard.Common.ControlChars.Colon);
                sb.Append(person.Y);
            });

            Assert.IsTrue(sb.Length > 50);
        }
        public void HasItemsTest()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10);

            Assert.IsTrue(collection.HasItems());

            Assert.IsTrue(collection.HasItems(10));

            Assert.IsTrue(collection.ToObservableCollection().HasItems());

            Assert.IsTrue(collection.ToObservableCollection().HasItems(10));

            Assert.IsTrue(collection.ToList().HasItems());

            Assert.IsTrue(collection.ToList().HasItems(10));

            Assert.IsFalse(collection.ToList().HasItems(p => p.X == 999999999));
        }
        public void ContainsAnyTest()
        {
            var collection      = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToList();
            var emptyCollection = new PersonCollection <PersonProper>();
            var coordinate      = RandomData.GenerateCoordinate <Coordinate>();

            //Test params
            Assert.IsFalse(collection.ContainsAny());
            Assert.IsFalse(collection.ToArray().ContainsAny());
            Assert.IsFalse(emptyCollection.ContainsAny());

            Assert.IsFalse(collection.ContainsAny(coordinate));

            collection.Add(coordinate);

            Assert.IsTrue(collection.ContainsAny(coordinate));

            Assert.IsTrue(collection.ToArray().ContainsAny(coordinate));
        }
        public void HasItemsTest01()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10);

            Assert.IsTrue(collection.ToList().HasItems());
        }
Esempio n. 19
0
        public void HasItemsTest02()
        {
            var collection = RandomData.GenerateCoordinateCollection <Coordinate>(10).ToCollection();

            Assert.IsFalse(collection.HasItems(5));
        }
Esempio n. 20
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);
        }