Skip to content

Commit

Permalink
More whitespaces and code style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Nov 1, 2021
1 parent a1db224 commit eab4b9e
Show file tree
Hide file tree
Showing 17 changed files with 631 additions and 623 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,45 +443,53 @@ public void ReplaceGroupInSource_ShoudReplaceGroup()
private static bool IsAddEventValid(NotifyCollectionChangedEventArgs args, IEnumerable<int> expectedGroupItems, int addIndex)
{
IEnumerable<IEnumerable<int>>? newItems = args.NewItems?.Cast<IEnumerable<int>>();
return args.Action == NotifyCollectionChangedAction.Add &&
args.NewStartingIndex == addIndex &&
args.OldItems == null &&
newItems?.Count() == 1 &&
Enumerable.SequenceEqual(newItems.ElementAt(0), expectedGroupItems);

return
args.Action == NotifyCollectionChangedAction.Add &&
args.NewStartingIndex == addIndex &&
args.OldItems == null &&
newItems?.Count() == 1 &&
Enumerable.SequenceEqual(newItems.ElementAt(0), expectedGroupItems);
}

private static bool IsRemoveEventValid(NotifyCollectionChangedEventArgs args, IEnumerable<int> expectedGroupItems, int oldIndex)
{
IEnumerable<IEnumerable<int>>? oldItems = args.OldItems?.Cast<IEnumerable<int>>();
return args.Action == NotifyCollectionChangedAction.Remove &&
args.NewItems == null &&
args.OldStartingIndex == oldIndex &&
oldItems?.Count() == 1 &&
Enumerable.SequenceEqual(oldItems.ElementAt(0), expectedGroupItems);

return
args.Action == NotifyCollectionChangedAction.Remove &&
args.NewItems == null &&
args.OldStartingIndex == oldIndex &&
oldItems?.Count() == 1 &&
Enumerable.SequenceEqual(oldItems.ElementAt(0), expectedGroupItems);
}

private static bool IsMoveEventValid(NotifyCollectionChangedEventArgs args, IEnumerable<int> expectedGroupItems, int oldIndex, int newIndex)
{
IEnumerable<IEnumerable<int>>? oldItems = args.OldItems?.Cast<IEnumerable<int>>();
IEnumerable<IEnumerable<int>>? newItems = args.NewItems?.Cast<IEnumerable<int>>();
return args.Action == NotifyCollectionChangedAction.Move &&
args.OldStartingIndex == oldIndex &&
args.NewStartingIndex == newIndex &&
oldItems?.Count() == 1 &&
Enumerable.SequenceEqual(oldItems.ElementAt(0), expectedGroupItems) &&
newItems?.Count() == 1 &&
Enumerable.SequenceEqual(newItems.ElementAt(0), expectedGroupItems);

return
args.Action == NotifyCollectionChangedAction.Move &&
args.OldStartingIndex == oldIndex &&
args.NewStartingIndex == newIndex &&
oldItems?.Count() == 1 &&
Enumerable.SequenceEqual(oldItems.ElementAt(0), expectedGroupItems) &&
newItems?.Count() == 1 &&
Enumerable.SequenceEqual(newItems.ElementAt(0), expectedGroupItems);
}

private static bool IsReplaceEventValid(NotifyCollectionChangedEventArgs args, IEnumerable<int> expectedRemovedItems, IEnumerable<int> expectedAddItems)
{
IEnumerable<IEnumerable<int>>? oldItems = args.OldItems?.Cast<IEnumerable<int>>();
IEnumerable<IEnumerable<int>>? newItems = args.NewItems?.Cast<IEnumerable<int>>();
return args.Action == NotifyCollectionChangedAction.Replace &&
oldItems?.Count() == 1 &&
Enumerable.SequenceEqual(oldItems.ElementAt(0), expectedRemovedItems) &&
newItems?.Count() == 1 &&
Enumerable.SequenceEqual(newItems.ElementAt(0), expectedAddItems);

return
args.Action == NotifyCollectionChangedAction.Replace &&
oldItems?.Count() == 1 &&
Enumerable.SequenceEqual(oldItems.ElementAt(0), expectedRemovedItems) &&
newItems?.Count() == 1 &&
Enumerable.SequenceEqual(newItems.ElementAt(0), expectedAddItems);
}

private static bool IsResetEventValid(NotifyCollectionChangedEventArgs args) => args.Action == NotifyCollectionChangedAction.Reset && args.NewItems == null && args.OldItems == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public void Test_ArrayExtensions_Jagged_GetColumn()
{
int[][] array =
{
new int[] { 5, 2, 4 },
new int[] { 6, 3 },
new int[] { 7 }
};
new int[] { 5, 2, 4 },
new int[] { 6, 3 },
new int[] { 7 }
};

int[]? col = array.GetColumn(1).ToArray();

Expand All @@ -34,20 +34,20 @@ public void Test_ArrayExtensions_Jagged_GetColumn_Exception()
{
int[][] array =
{
new int[] { 5, 2, 4 },
new int[] { 6, 3 },
new int[] { 7 }
};
new int[] { 5, 2, 4 },
new int[] { 6, 3 },
new int[] { 7 }
};

_ = Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
_ = array.GetColumn(-1).ToArray();
});
{
_ = array.GetColumn(-1).ToArray();
});

_ = Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
_ = array.GetColumn(3).ToArray();
});
{
_ = array.GetColumn(3).ToArray();
});
}

[TestCategory("ArrayExtensions")]
Expand All @@ -56,10 +56,10 @@ public void Test_ArrayExtensions_Rectangular_ToString()
{
int[,] array =
{
{ 5, 2, 4 },
{ 6, 3, -1 },
{ 7, 0, 9 }
};
{ 5, 2, 4 },
{ 6, 3, -1 },
{ 7, 0, 9 }
};

string value = array.ToArrayString();

Expand All @@ -74,10 +74,10 @@ public void Test_ArrayExtensions_Jagged_ToString()
{
int[][] array =
{
new int[] { 5, 2 },
new int[] { 6, 3, -1, 2 },
new int[] { 7, 0, 9 }
};
new int[] { 5, 2 },
new int[] { 6, 3, -1, 2 },
new int[] { 7, 0, 9 }
};

string value = array.ToArrayString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public void Test_EventHandlerExtensions_MultipleHandlersCauseAwait(int firstToRe
{
TaskCompletionSource<bool>[]? tsc = new[]
{
new TaskCompletionSource<bool>(),
new TaskCompletionSource<bool>()
};
new TaskCompletionSource<bool>(),
new TaskCompletionSource<bool>()
};

TestClass? testClass = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public void Test_ReadOnlyRefEnumerable_DangerousCreate_Ok(int length, int step,
{
Span<int> data = new[]
{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};

ReadOnlyRefEnumerable<int> enumerable = ReadOnlyRefEnumerable<int>.DangerousCreate(in data[0], length, step);

Expand Down Expand Up @@ -58,11 +58,11 @@ public void Test_ReadOnlyRefEnumerable_Indexer(int step, int[] values)
{
Span<int> data = new[]
{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};

ReadOnlyRefEnumerable<int> enumerable = ReadOnlyRefEnumerable<int>.DangerousCreate(in data[0], values.Length, step);

Expand All @@ -78,8 +78,8 @@ public void Test_ReadOnlyRefEnumerable_Indexer_ThrowsIndexOutOfRange()
{
int[] array = new[]
{
0, 0, 0, 0
};
0, 0, 0, 0
};

_ = Assert.ThrowsException<IndexOutOfRangeException>(() => ReadOnlyRefEnumerable<int>.DangerousCreate(in array[0], array.Length, 1)[-1]);
_ = Assert.ThrowsException<IndexOutOfRangeException>(() => ReadOnlyRefEnumerable<int>.DangerousCreate(in array[0], array.Length, 1)[array.Length]);
Expand All @@ -96,11 +96,11 @@ public void Test_ReadOnlyRefEnumerable_Index_Indexer(int step, int[] values)
{
Span<int> data = new[]
{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};

ReadOnlyRefEnumerable<int> enumerable = ReadOnlyRefEnumerable<int>.DangerousCreate(in data[0], values.Length, step);

Expand All @@ -116,8 +116,8 @@ public void Test_ReadOnlyRefEnumerable_Index_Indexer_ThrowsIndexOutOfRange()
{
int[] array = new[]
{
0, 0, 0, 0
};
0, 0, 0, 0
};

_ = Assert.ThrowsException<IndexOutOfRangeException>(() => ReadOnlyRefEnumerable<int>.DangerousCreate(in array[0], array.Length, 1)[new Index(array.Length)]);
_ = Assert.ThrowsException<IndexOutOfRangeException>(() => ReadOnlyRefEnumerable<int>.DangerousCreate(in array[0], array.Length, 1)[^0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public void Test_RefEnumerable_DangerousCreate_Ok(int length, int step, int[] va
{
Span<int> data = new[]
{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};

RefEnumerable<int> enumerable = RefEnumerable<int>.DangerousCreate(ref data[0], length, step);

Expand Down Expand Up @@ -58,11 +58,11 @@ public void Test_RefEnumerable_Indexer(int step, int[] values)
{
Span<int> data = new[]
{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};

RefEnumerable<int> enumerable = RefEnumerable<int>.DangerousCreate(ref data[0], values.Length, step);

Expand All @@ -78,8 +78,8 @@ public void Test_RefEnumerable_Indexer_ThrowsIndexOutOfRange()
{
int[] array = new[]
{
0, 0, 0, 0
};
0, 0, 0, 0
};

_ = Assert.ThrowsException<IndexOutOfRangeException>(() => RefEnumerable<int>.DangerousCreate(ref array[0], array.Length, 1)[-1]);
_ = Assert.ThrowsException<IndexOutOfRangeException>(() => RefEnumerable<int>.DangerousCreate(ref array[0], array.Length, 1)[array.Length]);
Expand All @@ -96,11 +96,11 @@ public void Test_RefEnumerable_Index_Indexer(int step, int[] values)
{
Span<int> data = new[]
{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};

RefEnumerable<int> enumerable = RefEnumerable<int>.DangerousCreate(ref data[0], values.Length, step);

Expand All @@ -116,8 +116,8 @@ public void Test_RefEnumerable_Index_Indexer_ThrowsIndexOutOfRange()
{
int[] array = new[]
{
0, 0, 0, 0
};
0, 0, 0, 0
};

_ = Assert.ThrowsException<IndexOutOfRangeException>(() => RefEnumerable<int>.DangerousCreate(ref array[0], array.Length, 1)[new Index(array.Length)]);
_ = Assert.ThrowsException<IndexOutOfRangeException>(() => RefEnumerable<int>.DangerousCreate(ref array[0], array.Length, 1)[^0]);
Expand Down
Loading

0 comments on commit eab4b9e

Please sign in to comment.