Skip to content

Commit

Permalink
Ensure All Collection Extensions Has Consistant DoesNotHaveItems Meth…
Browse files Browse the repository at this point in the history
…ods #53. Implemented in appropriate classes. Code cleanup.
  • Loading branch information
RealDotNetDave committed Jun 17, 2022
1 parent fc081f3 commit 90b350e
Show file tree
Hide file tree
Showing 19 changed files with 399 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 12-17-2020
//
// Last Modified By : David McCarter
// Last Modified On : 02-13-2021
// Last Modified On : 05-28-2022
// ***********************************************************************
// <copyright file="TypeHelperTests.cs" company="DotNetTips.Spargine.Core.Tests">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 12-17-2020
//
// Last Modified By : David McCarter
// Last Modified On : 06-15-2022
// Last Modified On : 06-17-2022
// ***********************************************************************
// <copyright file="ArrayExtensionsTests.cs" company="dotNetTips.Spargine.Extensions.Tests">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand Down Expand Up @@ -37,18 +37,6 @@ public void AddFirstTest()
Assert.IsTrue(result.FastCount() == 11);
}

[TestMethod]
public void FastProcessorTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(100).ToArray();

people.FastProcessor((PersonProper person) =>
{
person.Address2 = "TEST DATA";
});
}

[TestMethod]
public void AddIfTest()
{
Expand Down Expand Up @@ -100,44 +88,6 @@ public void AreEqualTest()
Assert.IsFalse(people1.AreEqual(arrayToCheck: null));
}

[TestMethod]
public void HasItemsTest()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

Assert.IsTrue(people1.HasItems());

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

[TestMethod]
public void HasItemsTestWithFunction()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

Func<PersonProper, bool> selector = (person) => person.Email.IsNotNull();

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

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

[TestMethod]
public void HasItemsTestWithCount()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

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

Assert.IsFalse(people1.HasItems(100));

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

}

[TestMethod]
public void BytesToStringTest()
{
Expand Down Expand Up @@ -193,6 +143,67 @@ public void ContainsAnyTest()

}

[TestMethod]
public void DoesNotHasItemsTest()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

Assert.IsFalse(people1.DoesNotHaveItems());

Assert.IsTrue(nullPeople.DoesNotHaveItems());
}

[TestMethod]
public void FastProcessorTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(100).ToArray();

people.FastProcessor((PersonProper person) =>
{
person.Address2 = "TEST DATA";
});
}

[TestMethod]
public void HasItemsTest()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

Assert.IsTrue(people1.HasItems());

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

[TestMethod]
public void HasItemsTestWithCount()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

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

Assert.IsFalse(people1.HasItems(100));

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

}

[TestMethod]
public void HasItemsTestWithFunction()
{
var people1 = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToArray();
PersonProper[] nullPeople = null;

Func<PersonProper, bool> selector = (person) => person.Email.IsNotNull();

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

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

[TestMethod]
public void RemoveDuplicatesTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 12-17-2020
//
// Last Modified By : David McCarter
// Last Modified On : 06-15-2022
// Last Modified On : 06-17-2022
// ***********************************************************************
// <copyright file="DictionaryExtensionsTests.cs" company="dotNetTips.Spargine.Extensions.Tests">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand Down Expand Up @@ -51,39 +51,6 @@ public void AddIfNotExistDictionaryTest()

}

[TestMethod]
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());
}

[TestMethod]
public void HasItemsWithCountTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);
Dictionary<string, PersonProper> nullPeople = null;

Assert.IsTrue(people.HasItems(10));
Assert.IsFalse(people.HasItems(100));

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

[TestMethod]
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));
}

[TestMethod]
public void AddRangeDictionaryTest01()
{
Expand All @@ -109,6 +76,17 @@ public void AddRangeDictionaryTest02()

}

[TestMethod]
public void DoesNotHaveItemsTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);
Dictionary<string, PersonProper> nullPeople = null;

Assert.IsTrue(people.DoesNotHaveItems());

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

[TestMethod]
public void GetOrAddTest()
{
Expand All @@ -125,6 +103,39 @@ public void GetOrAddTest()
_ = people.GetOrAdd(newPerson.Id, newPerson);
Assert.IsTrue(people.FastCount() == 11);
}

[TestMethod]
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());
}

[TestMethod]
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));
}

[TestMethod]
public void HasItemsWithCountTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToDictionary(p => p.Id);
Dictionary<string, PersonProper> nullPeople = null;

Assert.IsTrue(people.HasItems(10));
Assert.IsFalse(people.HasItems(100));

Assert.IsFalse(nullPeople.HasItems(10));
}
[TestMethod]
public void ToDelimitedDictionaryTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,6 @@ public void AdTest()
Assert.IsTrue(result.FastCount() == 11);
}

[TestMethod]
public void FastParallelProcessorTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(100).AsEnumerable();

var task = people.FastParallelProcessor((PersonProper person) =>
{
person.Address2 = "TEST DATA";
}, App.MaxDegreeOfParallelism());

Debug.WriteLine(task.IsCompleted);
}


[TestMethod]
public void ContainsAnyTest()
Expand Down Expand Up @@ -130,6 +116,20 @@ public void FastCountTest()
Assert.IsNotNull(people.FastCount(p => p.City.Contains('A', StringComparison.CurrentCultureIgnoreCase)));
}

[TestMethod]
public void FastParallelProcessorTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(100).AsEnumerable();

var task = people.FastParallelProcessor((PersonProper person) =>
{
person.Address2 = "TEST DATA";
}, App.MaxDegreeOfParallelism());

Debug.WriteLine(task.IsCompleted);
}

[TestMethod]
public void FirstOrDefaultTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 01-16-2022
//
// Last Modified By : David McCarter
// Last Modified On : 06-15-2022
// Last Modified On : 06-17-2022
// ***********************************************************************
// <copyright file="ImmutableArrayTests.cs" company="dotNetTips.Spargine.Extensions.Tests">
// Copyright (c) dotNetTips.com - David McCarter. All rights reserved.
Expand All @@ -25,14 +25,6 @@ namespace DotNetTips.Spargine.Extensions.Tests
[TestClass]
public class ImmutableArrayTests
{
[TestMethod]
public void ImmutableArrayTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToHashSet().ToImmutable();
var copyPeople = people;
Assert.IsTrue(people == copyPeople);
Assert.IsFalse(people == copyPeople.Shuffle());
}

[TestMethod]
public void HasItemsTest()
Expand All @@ -55,5 +47,13 @@ public void HasItemsTestWithCount()

Assert.IsFalse(nullCollection.HasItems());
}
[TestMethod]
public void ImmutableArrayTest()
{
var people = RandomData.GeneratePersonRefCollection<PersonProper>(10).ToHashSet().ToImmutable();
var copyPeople = people;
Assert.IsTrue(people == copyPeople);
Assert.IsFalse(people == copyPeople.Shuffle());
}
}
}
Loading

0 comments on commit 90b350e

Please sign in to comment.