public void CopyToListTest()
        {
            var people    = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToList();
            var newPeople = people.CopyToCollection();

            Assert.IsTrue(people.FastCount() == newPeople.FastCount());
        }
Exemple #2
0
        public void ToObservableCollectionTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10);

            //Test
            Assert.IsTrue(people.ToObservableCollection().HasItems());
        }
        public void GetTypeDisplayNameTest()
        {
            var person = RandomData.GenerateRefPerson <PersonProper>();

            var result = TypeHelper.GetTypeDisplayName(person);

            Assert.IsTrue(string.Compare(result, "DotNetTips.Spargine.Tester.Models.RefTypes.PersonProper", StringComparison.Ordinal) == 0);

            result = TypeHelper.GetTypeDisplayName(person, true);

            Assert.IsTrue(string.Compare(result, "DotNetTips.Spargine.Tester.Models.RefTypes.PersonProper", StringComparison.Ordinal) == 0);

            result = TypeHelper.GetTypeDisplayName(typeof(int), true, true, true, '-');

            Assert.IsTrue(string.Compare(result, "int", StringComparison.Ordinal) == 0);

            var people = RandomData.GeneratePersonRefCollection <PersonProper>(5);

            result = TypeHelper.GetTypeDisplayName(people);

            Assert.IsTrue(result.Length > 0);

            result = TypeHelper.GetTypeDisplayName(RandomData.GenerateRefPerson <Person>());

            Assert.IsTrue(result.Length > 0);
        }
        public void AddLastTest()
        {
            var          peopleList  = RandomData.GeneratePersonRefCollection <PersonProper>(10);
            var          peopleArray = peopleList.ToArray();
            var          person      = RandomData.GenerateRefPerson <PersonProper>();
            PersonProper nullPerson  = null;

            //Test Parameters
            _ = Assert.ThrowsException <ArgumentReadOnlyException>(() => peopleList.ToReadOnlyCollection()
                                                                   .AddLast(person));

            // Test List
            peopleList.AddLast(nullPerson);
            Assert.IsTrue(peopleList.FastCount() == peopleList.FastCount());

            peopleList.AddLast(person);
            Assert.IsTrue(peopleList.Last().Equals(person));


            // Test Array
            var result2 = peopleArray.AddLast(person);

            Assert.IsTrue(result2.Last().Equals(person));
            Assert.IsTrue(peopleArray.AddLast(null).Length == peopleArray.Length);
        }
        public void CountTest()
        {
            const int Count  = 10;
            var       people = RandomData.GeneratePersonRefCollection <PersonProper>(Count).AsEnumerable();

            Assert.IsTrue(people.FastCount() == Count);
        }
        public void AppendKeyValueTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToDictionary(p => p.Id);

            var sb = new StringBuilder();

            foreach (var person in people)
            {
                sb.AppendKeyValue(person.Key, person.Value.Email);
                sb.AppendKeyValue(person.Key, person.Value.Email, includeQuotes: Tristate.True);
                sb.AppendKeyValue(person.Key, person.Value.Email, includeComma: Tristate.True);
                sb.AppendKeyValue(person.Key, person.Value.Email, includeQuotes: Tristate.True, includeComma: Tristate.True);
            }

            Assert.IsTrue(sb.ToString().Length > 50 * 4);

            var pool = new StringBuilder();

            foreach (var person in people)
            {
                pool.AppendKeyValue(person.Key, person.Value.Email);
                pool.AppendKeyValue(person.Key, person.Value.Email, includeQuotes: Tristate.True);
                pool.AppendKeyValue(person.Key, person.Value.Email, includeComma: Tristate.True);
                pool.AppendKeyValue(person.Key, person.Value.Email, includeQuotes: Tristate.True, includeComma: Tristate.True);
            }

            Assert.IsTrue(pool.ToString().Length > 50 * 4);
        }
Exemple #7
0
        public void ConstructorsTest()
        {
            var comparer = new PersonProperComparer();

            var test1 = new ConcurrentHashSet <PersonProper>();

            Assert.IsNotNull(test1);

            var test2 = new ConcurrentHashSet <PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(100));

            Assert.IsNotNull(test2);
            Assert.IsTrue(test2.Count == 100);

            var test3 = new ConcurrentHashSet <PersonProper>(comparer);

            Assert.IsNotNull(test3);

            var test4 = new ConcurrentHashSet <PersonProper>(2, 100);

            Assert.IsNotNull(test4);

            var test5 = new ConcurrentHashSet <PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(100), comparer);

            Assert.IsNotNull(test5);
            Assert.IsTrue(test5.Count == 100);

            var test6 = new ConcurrentHashSet <PersonProper>(2, 100, comparer);

            Assert.IsNotNull(test6);

            var test7 = new ConcurrentHashSet <PersonProper>(2, RandomData.GeneratePersonRefCollection <PersonProper>(100), comparer);

            Assert.IsNotNull(test7);
            Assert.IsTrue(test7.Count == 100);
        }
Exemple #8
0
        public void GetEnumeratorTest()
        {
            var people = new ConcurrentHashSet <PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(100));

            var result = people.GetEnumerator();

            Assert.IsNotNull(result);
        }
        /// <summary>
        /// Loads the person reference array.
        /// </summary>
        protected void LoadPersonRefArray()
        {
            this._personRefArray = RandomData.GeneratePersonRefCollection <Person>(this.MaxCount).ToArray();
            ConsoleLogger.Default.WriteLine($"{nameof(this._personRefArray)} Length = {this._personRefArray.Length}.");

            this._personRefArrayHalf = RandomData.GeneratePersonRefCollection <Person>(this.MaxCount / 2).ToArray();
            ConsoleLogger.Default.WriteLine($"{nameof(this._personRefArrayHalf)} Length = {this._personRefArrayHalf.Length}.");
        }
        public void PickRandomTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToDictionary(p => p.Id);

            var result = people.PickRandom();

            Assert.IsNotNull(result);
        }
        public void ToSortedDictionaryTest()
        {
            var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);

            var result = people.ToSortedDictionary();

            Assert.IsTrue(result.HasItems());
        }
        public void HasItemsTestWithFunction()
        {
            var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);

            Func<KeyValuePair<string, PersonProper>, bool> selector = p => p.Value.Email.IsNotNull();

            Assert.IsTrue(people.HasItems(selector));
        }
Exemple #13
0
        public void ToImmutableTest()
        {
            var peopleSortedSet = new SortedSet <PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(100));

            var result = peopleSortedSet.ToImmutable();

            Assert.IsNotNull(result);
        }
Exemple #14
0
        public void IsNumericTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10).AsEnumerable();
            var person = RandomData.GenerateRefPerson <PersonProper>();

            Assert.IsTrue(people.GetType().IsEnumerable());
            Assert.IsFalse(person.GetType().IsEnumerable());
        }
        public void CloneTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToArray();

            var result = people.Clone <PersonProper>();

            Assert.IsTrue(people.AreEqual(result));
        }
        public async Task ToListAsyncTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(50).AsEnumerable();

            var result = await people.ToListAsync().ConfigureAwait(false);

            Assert.IsNotNull(result);
        }
        public void ImmutableArrayTest()
        {
            var people     = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToHashSet().ToImmutable();
            var copyPeople = people;

            Assert.IsTrue(people == copyPeople);
            Assert.IsFalse(people == copyPeople.Shuffle());
        }
Exemple #18
0
        public void GeneratePersonCollectionTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(Count);

            Assert.IsNotNull(people);

            Assert.IsTrue(people.FastCount() == Count);
        }
        public void HasItemsTest()
        {
            var collection = RandomData.GeneratePersonRefCollection <PersonProper>(10).AsEnumerable();
            IEnumerable <PersonProper> nullCollection = null;

            Assert.IsTrue(collection.HasItems());

            Assert.IsFalse(nullCollection.HasItems());
        }
Exemple #20
0
        public void HasItemsTest()
        {
            var collection = new SortedSet <PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(100));
            SortedSet <PersonProper> nullCollection = null;

            Assert.IsTrue(collection.HasItems());

            Assert.IsFalse(nullCollection.HasItems());
        }
        public void DoesNotHaveItemsTest()
        {
            var people      = RandomData.GeneratePersonRefCollection <PersonProper>(10);
            var emptyPeople = new List <PersonProper>();

            Assert.IsFalse(people.DoesNotHaveItems());

            Assert.IsTrue(emptyPeople.DoesNotHaveItems());
        }
        public void AddTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToArray();
            var person = RandomData.GenerateRefPerson <PersonProper>();

            var result = people.Add(person);

            Assert.IsTrue(result.FastCount() == 11);
        }
        public void FastProcessorTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(100).ToArray();

            people.FastProcessor((PersonProper person) =>
            {
                person.Address2 = "TEST DATA";
            });
        }
        public void HasItemsTest()
        {
            var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);
            Dictionary<string, PersonProper> nullPeople = null;

            Assert.IsTrue(people.HasItems());

            Assert.IsFalse(nullPeople.HasItems());
        }
        public void AddRangeDictionaryTest02()
        {
            var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);
            var people2 = RandomData.GeneratePersonRefCollection<PersonProper>(2).ToDictionary(p => p.Id);

            Assert.IsTrue(people1.AddRange(people2));

            Assert.IsTrue(people1.FastCount() == 12);
        }
        public void ToBlockingTest()
        {
            const int Count  = 10;
            var       people = RandomData.GeneratePersonRefCollection <PersonProper>(Count).AsEnumerable();

            var result = people.ToBlockingCollection();

            Assert.IsTrue(result.FastCount() == Count);
        }
        public void ShuffleWithCountTest()
        {
            var people = RandomData.GeneratePersonRefCollection <PersonProper>(10);
            List <PersonProper> nullList = null;

            _ = Assert.ThrowsException <ArgumentNullException>(nullList.Shuffle);

            Assert.IsTrue(people.Shuffle(5).FastCount() == 5);
        }
Exemple #28
0
        public void DoesNotHaveItemsTest()
        {
            var peopleSortedSet = new SortedDictionary <string, PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(10).ToDictionary(p => p.Id));
            SortedDictionary <string, PersonProper> nullPeople = null;

            Assert.IsFalse(peopleSortedSet.DoesNotHaveItems());

            Assert.IsTrue(nullPeople.DoesNotHaveItems());
        }
Exemple #29
0
        public void AddTest()
        {
            var people = new ConcurrentHashSet <PersonProper>(RandomData.GeneratePersonRefCollection <PersonProper>(100));

            var result = people.Add(RandomData.GenerateRefPerson <PersonProper>());

            Assert.IsTrue(result);
            Assert.IsTrue(people.Count == 101);
        }
        public void HasItemsTest()
        {
            var people1 = RandomData.GeneratePersonRefCollection <PersonProper>(10).ToArray();

            PersonProper[] nullPeople = null;

            Assert.IsTrue(people1.HasItems());

            Assert.IsFalse(nullPeople.HasItems());
        }