mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
Tidying
This commit is contained in:
@@ -37,7 +37,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
Assert.AreEqual(0, result);
|
||||
Assert.AreEqual(false, exists);
|
||||
|
||||
sequence = new int[] { expected };
|
||||
sequence = new[] { expected };
|
||||
exists = sequence.TryFirst(out result);
|
||||
|
||||
Assert.AreEqual(expected, result);
|
||||
@@ -55,7 +55,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
Assert.AreEqual(0, result);
|
||||
Assert.AreEqual(false, exists);
|
||||
|
||||
sequence = new int[] { expected };
|
||||
sequence = new[] { expected };
|
||||
exists = sequence.TryFirst(i => i == expected, out result);
|
||||
|
||||
Assert.AreEqual(expected, result);
|
||||
@@ -73,7 +73,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
Assert.AreEqual(0, result);
|
||||
Assert.AreEqual(false, exists);
|
||||
|
||||
sequence = new int[] { expected };
|
||||
sequence = new[] { expected };
|
||||
exists = sequence.TryElementAt(0, out result);
|
||||
|
||||
Assert.AreEqual(expected, result);
|
||||
@@ -83,8 +83,8 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void SequenceEqualTest()
|
||||
{
|
||||
int[] a = new int[] { 1, 2, 3, 4};
|
||||
int[] b = new int[] { 1, 4, 9, 16};
|
||||
int[] a = new[] { 1, 2, 3, 4};
|
||||
int[] b = new[] { 1, 4, 9, 16};
|
||||
|
||||
Assert.IsFalse(a.SequenceEqual(b, (x, y) => x == y));
|
||||
Assert.IsTrue(a.SequenceEqual(b, (x, y) => x * x == y));
|
||||
@@ -93,10 +93,10 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ScrambledEqualsTest()
|
||||
{
|
||||
IEnumerable<int> a = new int[] { 1, 2, 3, 4 };
|
||||
IEnumerable<int> b = new int[] { 3, 1, 2, 4 };
|
||||
IEnumerable<int> c = new int[] { 1, 2, 3, 4, 4 };
|
||||
IEnumerable<int> d = new int[] { 1, 2, 3, 4, 5 };
|
||||
IEnumerable<int> a = new[] { 1, 2, 3, 4 };
|
||||
IEnumerable<int> b = new[] { 3, 1, 2, 4 };
|
||||
IEnumerable<int> c = new[] { 1, 2, 3, 4, 4 };
|
||||
IEnumerable<int> d = new[] { 1, 2, 3, 4, 5 };
|
||||
|
||||
Assert.IsTrue(a.ScrambledEquals(b));
|
||||
Assert.IsFalse(a.ScrambledEquals(c));
|
||||
@@ -106,10 +106,10 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ScrambledEqualsComparerTest()
|
||||
{
|
||||
IEnumerable<int> a = new int[] { 1, 2, 3, 4 };
|
||||
IEnumerable<int> b = new int[] { 3, 1, 2, 4 };
|
||||
IEnumerable<int> c = new int[] { 1, 2, 3, 4, 4 };
|
||||
IEnumerable<int> d = new int[] { 1, 2, 3, 4, 5 };
|
||||
IEnumerable<int> a = new[] { 1, 2, 3, 4 };
|
||||
IEnumerable<int> b = new[] { 3, 1, 2, 4 };
|
||||
IEnumerable<int> c = new[] { 1, 2, 3, 4, 4 };
|
||||
IEnumerable<int> d = new[] { 1, 2, 3, 4, 5 };
|
||||
|
||||
Assert.IsTrue(a.ScrambledEquals(b, EqualityComparer<int>.Default));
|
||||
Assert.IsFalse(a.ScrambledEquals(c, EqualityComparer<int>.Default));
|
||||
@@ -119,7 +119,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void FindIndexPredicateTest()
|
||||
{
|
||||
IEnumerable<int> a = new int[] { 1, 2, 3, 4 };
|
||||
IEnumerable<int> a = new[] { 1, 2, 3, 4 };
|
||||
Assert.AreEqual(2, a.FindIndex(i => i == 3));
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void PrependManyTest()
|
||||
{
|
||||
int[] values = (new int[] { 4, 5, 6 }).PrependMany(1, 2, 3).ToArray();
|
||||
int[] values = (new[] { 4, 5, 6 }).PrependMany(1, 2, 3).ToArray();
|
||||
|
||||
Assert.AreEqual(6, values.Length);
|
||||
Assert.AreEqual(1, values[0]);
|
||||
@@ -206,7 +206,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void AppendManyTest()
|
||||
{
|
||||
int[] values = (new int[] { 1, 2, 3 }).AppendMany(4, 5, 6).ToArray();
|
||||
int[] values = (new[] { 1, 2, 3 }).AppendMany(4, 5, 6).ToArray();
|
||||
|
||||
Assert.AreEqual(6, values.Length);
|
||||
Assert.AreEqual(1, values[0]);
|
||||
@@ -220,7 +220,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void OrderTest()
|
||||
{
|
||||
int[] values = (new int[] { 2, 3, 1 }).Order().ToArray();
|
||||
int[] values = (new[] { 2, 3, 1 }).Order().ToArray();
|
||||
|
||||
Assert.AreEqual(3, values.Length);
|
||||
Assert.AreEqual(1, values[0]);
|
||||
@@ -231,7 +231,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ExceptTest()
|
||||
{
|
||||
int[] values = (new int[] { 1, 2, 3 }).Except(2).ToArray();
|
||||
int[] values = (new[] { 1, 2, 3 }).Except(2).ToArray();
|
||||
|
||||
Assert.AreEqual(2, values.Length);
|
||||
Assert.AreEqual(1, values[0]);
|
||||
@@ -241,7 +241,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ToHashSetTest()
|
||||
{
|
||||
IcdHashSet<int> values = (new int[] { 1, 2, 3 }).ToHashSet();
|
||||
IcdHashSet<int> values = (new[] { 1, 2, 3 }).ToHashSet();
|
||||
|
||||
Assert.AreEqual(3, values.Count);
|
||||
Assert.IsTrue(values.Contains(1));
|
||||
@@ -252,7 +252,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ToDictionaryIntTest()
|
||||
{
|
||||
Dictionary<int, int> values = (new int[] { 1, 2, 3 }).ToDictionary();
|
||||
Dictionary<int, int> values = (new[] { 1, 2, 3 }).ToDictionary();
|
||||
|
||||
Assert.AreEqual(3, values.Count);
|
||||
Assert.AreEqual(1, values[0]);
|
||||
@@ -263,7 +263,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ToDictionaryUIntTest()
|
||||
{
|
||||
Dictionary<uint, int> values = (new int[] { 1, 2, 3 }).ToDictionaryUInt();
|
||||
Dictionary<uint, int> values = (new[] { 1, 2, 3 }).ToDictionaryUInt();
|
||||
|
||||
Assert.AreEqual(3, values.Count);
|
||||
Assert.AreEqual(1, values[0]);
|
||||
@@ -292,24 +292,24 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void UnanimousTest()
|
||||
{
|
||||
Assert.IsTrue((new bool[] { true, true, true}).Unanimous());
|
||||
Assert.IsTrue((new bool[] { false, false, false }).Unanimous());
|
||||
Assert.IsFalse((new bool[] { false, true, false }).Unanimous());
|
||||
Assert.IsTrue((new[] { true, true, true}).Unanimous());
|
||||
Assert.IsTrue((new[] { false, false, false }).Unanimous());
|
||||
Assert.IsFalse((new[] { false, true, false }).Unanimous());
|
||||
Assert.IsFalse((new bool[] { }).Unanimous());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnanimousOtherTest()
|
||||
{
|
||||
Assert.AreEqual("A", (new string[] { "A", "A", "A" }).Unanimous("B"));
|
||||
Assert.AreEqual("C", (new string[] { "B", "A", "B" }).Unanimous("C"));
|
||||
Assert.AreEqual("A", (new[] { "A", "A", "A" }).Unanimous("B"));
|
||||
Assert.AreEqual("C", (new[] { "B", "A", "B" }).Unanimous("C"));
|
||||
Assert.AreEqual("A", (new string[] { }).Unanimous("A"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PartitionTest()
|
||||
{
|
||||
int[][] items = (new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }).Partition(3)
|
||||
int[][] items = (new[] { 1, 2, 3, 4, 5, 6, 7, 8 }).Partition(3)
|
||||
.Select(p => p.ToArray())
|
||||
.ToArray();
|
||||
|
||||
@@ -337,10 +337,10 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
IEnumerable<int> a = new int[] {};
|
||||
Assert.AreEqual(0, a.GetAdjacentPairs().Count());
|
||||
|
||||
IEnumerable<int> b = new int[] { 1 };
|
||||
IEnumerable<int> b = new[] { 1 };
|
||||
Assert.AreEqual(0, b.GetAdjacentPairs().Count());
|
||||
|
||||
IEnumerable<int> c = new int[] { 1, 2, 3 };
|
||||
IEnumerable<int> c = new[] { 1, 2, 3 };
|
||||
int[][] cPairs = c.GetAdjacentPairs().ToArray();
|
||||
|
||||
Assert.AreEqual(2, cPairs.Length);
|
||||
@@ -353,14 +353,14 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void MinByTest()
|
||||
{
|
||||
Assert.AreEqual(1, (new int[] { 3, 6, 2, 7, 1 }).MinBy(i => i));
|
||||
Assert.AreEqual(1, new[] { 3, 6, 2, 7, 1 }.MinBy(i => i));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MinByComparerTest()
|
||||
{
|
||||
IComparer<int> comparer = new NegativeComparer();
|
||||
Assert.AreEqual(7, (new int[] { 3, 6, 2, 7, 1 }).MinBy(i => i, comparer));
|
||||
Assert.AreEqual(7, new[] { 3, 6, 2, 7, 1 }.MinBy(i => i, comparer));
|
||||
}
|
||||
|
||||
private class NegativeComparer : IComparer<int>
|
||||
@@ -394,7 +394,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ConsolidateTest()
|
||||
{
|
||||
string[] sequence = EnumerableExtensions.Consolidate(new string[] { "A", "B", "B", "C" }).ToArray();
|
||||
string[] sequence = EnumerableExtensions.Consolidate(new[] { "A", "B", "B", "C" }).ToArray();
|
||||
|
||||
Assert.AreEqual(3, sequence.Length, StringUtils.ArrayFormat(sequence));
|
||||
Assert.AreEqual("A", sequence[0]);
|
||||
@@ -405,7 +405,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void ConsolidateComparerTest()
|
||||
{
|
||||
string[] sequence = EnumerableExtensions.Consolidate(new string[] { "A", "B", "B", "C" }, Comparer<string>.Default).ToArray();
|
||||
string[] sequence = EnumerableExtensions.Consolidate(new[] { "A", "B", "B", "C" }, Comparer<string>.Default).ToArray();
|
||||
|
||||
Assert.AreEqual(3, sequence.Length, StringUtils.ArrayFormat(sequence));
|
||||
Assert.AreEqual("A", sequence[0]);
|
||||
@@ -416,7 +416,7 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
[Test]
|
||||
public void AnyAndAllTest()
|
||||
{
|
||||
IEnumerable<int> sequence = new int[] { 1, 2, 3, 4 };
|
||||
IEnumerable<int> sequence = new[] { 1, 2, 3, 4 };
|
||||
|
||||
Assert.IsTrue(sequence.AnyAndAll(i => i > 0));
|
||||
Assert.IsFalse(sequence.AnyAndAll(i => i < 0));
|
||||
|
||||
Reference in New Issue
Block a user