diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index f5a8263..82c61e4 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -48,23 +48,6 @@ jobs: - name: Test Collections.EqualityComparers.Tests run: dotnet test ./src/*/*/Collections.EqualityComparers.Tests.csproj --no-restore -c Release - # Collections.FlatArray - - - name: Restore Collections.FlatArray - run: dotnet restore ./src/*/*/Collections.FlatArray.csproj - - - name: Build Collections.FlatArray - run: dotnet build ./src/*/*/Collections.FlatArray.csproj --no-restore -c Release - - - name: Pack Collections.FlatArray - run: dotnet pack ./src/*/*/Collections.FlatArray.csproj --no-restore -o ~/nuget -c Release - - - name: Restore Collections.FlatArray.Tests - run: dotnet restore ./src/*/*/Collections.FlatArray.Tests.csproj - - - name: Test Collections.FlatArray.Tests - run: dotnet test ./src/*/*/Collections.FlatArray.Tests.csproj --no-restore -c Release - # Collections - name: Restore Collections diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Collections.FlatArray.Tests.csproj b/src/collections-flat-array/Collections.FlatArray.Tests/Collections.FlatArray.Tests.csproj deleted file mode 100644 index de7a6c4..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Collections.FlatArray.Tests.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - net6.0 - disable - enable - true - true - false - Andrei Sergeev, Pavel Moskovoy - Copyright © 2022 Andrei Sergeev, Pavel Moskovoy - PrimeFuncPack.Collections.Tests - PrimeFuncPack.Collections.FlatArray.Tests - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder.Enumerator/Enumerator.Initialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder.Enumerator/Enumerator.Initialize.cs deleted file mode 100644 index f5f4a8f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder.Enumerator/Enumerator.Initialize.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static FlatArray.Builder.Enumerator InitializeEnumerator(this FlatArray.Builder builder, int index) - { - var source = default(FlatArray.Builder.Enumerator); - var type = typeof(FlatArray.Builder.Enumerator); - - type.CreateSetter>("builder").Invoke(source, builder); - type.CreateSetter>("index").Invoke(source, index); - - return source; - } - - private delegate void BuilderEnumeratorBuilderSetter(in FlatArray.Builder.Enumerator source, FlatArray.Builder builder); - - private delegate void BuilderEnumeratorIndexSetter(in FlatArray.Builder.Enumerator source, int index); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder.Enumerator/Enumerator.Verify.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder.Enumerator/Enumerator.Verify.cs deleted file mode 100644 index e31ab20..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder.Enumerator/Enumerator.Verify.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static void VerifyInnerState( - this FlatArray.Builder.Enumerator actual, T[]? expectedBuilderItems, int expectedBuilderLength, int expectedIndex) - { - var type = typeof(FlatArray.Builder.Enumerator); - - var actualBuilder = type.CreateGetter>("builder").Invoke(actual); - actualBuilder.VerifyInnerState(expectedBuilderItems, expectedBuilderLength); - - var actualIndex = type.CreateGetter>("index").Invoke(actual); - Assert.StrictEqual(expectedIndex, actualIndex); - } - - private delegate FlatArray.Builder BuilderEnumeratorBuilderGetter(in FlatArray.Builder.Enumerator source); - - private delegate int BuilderEnumeratorIndexGetter(in FlatArray.Builder.Enumerator source); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder/Builder.Initialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder/Builder.Initialize.cs deleted file mode 100644 index a3b8109..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder/Builder.Initialize.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static FlatArray.Builder InitializeFlatArrayBuilder(this T[] items, int? length = null) - { - var source = default(FlatArray.Builder); - var type = typeof(FlatArray.Builder); - - type.CreateSetter>("items").Invoke(source, items); - type.CreateSetter>("length").Invoke(source, length ?? items.Length); - - return source; - } - - private delegate void BuilderFieldSetter(in FlatArray.Builder source, TValue value); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder/Builder.Verify.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder/Builder.Verify.cs deleted file mode 100644 index 2d16302..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Builder/Builder.Verify.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static void VerifyInnerState(this FlatArray.Builder actual, T[]? expectedItems, int expectedLength) - { - var type = typeof(FlatArray.Builder); - - var actualItems = type.CreateGetter>("items").Invoke(actual); - Assert.Equal(expectedItems, actualItems); - - var actualLength = type.CreateGetter>("length").Invoke(actual); - Assert.StrictEqual(expectedLength, actualLength); - } - - private delegate TValue BuilderFieldGetter(in FlatArray.Builder source); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Enumerator/Enumerator.Initialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Enumerator/Enumerator.Initialize.cs deleted file mode 100644 index 3c4ceaf..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Enumerator/Enumerator.Initialize.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static FlatArray.Enumerator InitializeFlatArrayEnumerator(this T[] items, int index) - { - var source = default(FlatArray.Enumerator); - var type = typeof(FlatArray.Enumerator); - - type.CreateSetter>("items").Invoke(source, new(items)); - type.CreateSetter>("index").Invoke(source, index); - - return source; - } - - private delegate void EnumeratorItemsSetter(in FlatArray.Enumerator source, ReadOnlySpan items); - - private delegate void EnumeratorIndexSetter(in FlatArray.Enumerator source, int index); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Enumerator/Enumerator.Verify.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Enumerator/Enumerator.Verify.cs deleted file mode 100644 index cff6bc3..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray.Enumerator/Enumerator.Verify.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static void VerifyInnerState(this FlatArray.Enumerator actual, T[] expectedItems, int expectedIndex) - { - var type = typeof(FlatArray.Enumerator); - - var actualItems = type.CreateGetter>("items").Invoke(actual); - Assert.Equal(expectedItems, actualItems.ToArray()); - - var actualIndex = type.CreateGetter>("index").Invoke(actual); - Assert.StrictEqual(expectedIndex, actualIndex); - } - - private delegate ReadOnlySpan EnumeratorItemsGetter(in FlatArray.Enumerator source); - - private delegate int EnumeratorIndexGetter(in FlatArray.Enumerator source); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray/FlatArray.Initialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray/FlatArray.Initialize.cs deleted file mode 100644 index 883dcbf..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray/FlatArray.Initialize.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static FlatArray InitializeFlatArray(this T[] items, int? length = null) - { - Debug.Assert(items.Length is not 0); - - // Use a boxed default array instance to modify its inner state next - object array = default(FlatArray); - - array.SetFieldValue("length", length ?? items.Length); - array.SetFieldValue("items", items); - - return (FlatArray)array; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray/FlatArray.Verify.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray/FlatArray.Verify.cs deleted file mode 100644 index c9de061..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/FlatArray/FlatArray.Verify.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static void VerifyInnerState(this FlatArray actual, T[]? expectedItems, int expectedLength) - { - var actualLength = actual.GetStructFieldValue("length"); - Assert.StrictEqual(expectedLength, actualLength); - - var actualItems = actual.GetFieldValue("items"); - Assert.Equal(expectedItems, actualItems); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/Helper.GetCopy.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/Helper.GetCopy.cs deleted file mode 100644 index 443db04..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/Helper.GetCopy.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static T[] GetCopy(this T[] source) - { - if (source.Length is 0) - { - return Array.Empty(); - } - - var copy = new T[source.Length]; - Array.Copy(source, copy, source.Length); - - return copy; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList.Enumerator/Enumerator.Initialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList.Enumerator/Enumerator.Initialize.cs deleted file mode 100644 index e386f4f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList.Enumerator/Enumerator.Initialize.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static IEnumerator InitializeFlatListEnumerator(this T[] items, int length, int index) - { - var flatListEnumerator = items.InitializeFlatList(length).GetEnumerator(); - - flatListEnumerator.SetFieldValue("items", items); - flatListEnumerator.SetFieldValue("length", length); - flatListEnumerator.SetFieldValue("index", index); - - return flatListEnumerator; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList.Enumerator/Enumerator.Verify.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList.Enumerator/Enumerator.Verify.cs deleted file mode 100644 index 664bd3e..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList.Enumerator/Enumerator.Verify.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static void VerifyInnerFlatListEnumeratorState( - this IEnumerator actual, T[] expectedItems, int expectedLength, int expectedIndex) - { - var actualTypeName = actual.GetType().Name; - const string expectedTypeName = "InnerEnumerator"; - - Assert.Equal(expectedTypeName, actualTypeName); - - var actualItems = actual.GetFieldValue("items"); - Assert.Equal(expectedItems, actualItems); - - var actualLength = actual.GetStructFieldValue("length"); - Assert.StrictEqual(expectedLength, actualLength); - - var actualIndex = actual.GetStructFieldValue("index"); - Assert.StrictEqual(expectedIndex, actualIndex); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Empty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Empty.cs deleted file mode 100644 index b8e893d..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Empty.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static IList CreateEmptyFlatList() - => - (IList)default(FlatArray).AsEnumerable(); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Initialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Initialize.cs deleted file mode 100644 index 09d0eb3..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Initialize.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static IList InitializeFlatList(this T[] items, int? length = null) - { - var source = default(FlatArray).AsEnumerable(); - - source.SetFieldValue("length", length ?? items.Length); - source.SetFieldValue("items", items); - - return (IList)source; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Verify.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Verify.cs deleted file mode 100644 index 2603f08..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/InnerFlatList/InnerFlatList.Verify.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class TestHelper -{ - internal static void VerifyInnerFlatListState(this IEnumerable actual, T[] expectedItems, int expectedLength) - { - var actualTypeName = actual.GetType().Name; - const string expectedTypeName = "InnerFlatList"; - - Assert.Equal(expectedTypeName, actualTypeName); - - var actualLength = actual.GetStructFieldValue("length"); - Assert.StrictEqual(expectedLength, actualLength); - - var actualItems = actual.GetFieldValue("items"); - Assert.Equal(expectedItems, actualItems); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/TestHelper.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/TestHelper.cs deleted file mode 100644 index be9d6bd..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Internal.Helper/TestHelper.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Reflection; -using System.Reflection.Emit; - -namespace PrimeFuncPack.Collections.Tests; - -internal static partial class TestHelper -{ - private static T GetStructFieldValue(this object source, string fieldName) - where T : struct - => - source.GetType().GetInnerFieldInfoOrThrow(fieldName).GetValue(source) switch - { - T fieldValue => fieldValue, - var unexpected => throw new InvalidOperationException($"An unexpected field '{fieldName}' value: {unexpected}") - }; - - private static T? GetFieldValue(this object source, string fieldName) - => - (T?)source.GetType().GetInnerFieldInfoOrThrow(fieldName).GetValue(source); - - private static void SetFieldValue(this object source, string fieldName, T fieldValue) - => - source.GetType().GetInnerFieldInfoOrThrow(fieldName).SetValue(source, fieldValue); - - private static FieldInfo GetInnerFieldInfoOrThrow(this Type type, string fieldName) - => - type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic) - ?? throw new InvalidOperationException($"An inner field '{fieldName}' of the FlatArray type was not found"); - - private static TDelegate CreateGetter(this Type ownerType, string fieldName) - where TDelegate : Delegate - { - var fieldInfo = ownerType.GetInnerFieldInfoOrThrow(fieldName); - var methodName = "GetInner" + fieldName; - - var method = new DynamicMethod(methodName, fieldInfo.FieldType, new[] { ownerType.MakeByRefType() }, ownerType, true); - var ilGenerator = method.GetILGenerator(); - - ilGenerator.Emit(OpCodes.Ldarg_0); - ilGenerator.Emit(OpCodes.Ldfld, fieldInfo); - ilGenerator.Emit(OpCodes.Ret); - - return (TDelegate)method.CreateDelegate(typeof(TDelegate)); - } - - private static TDelegate CreateSetter(this Type ownerType, string fieldName) - where TDelegate : Delegate - { - var fieldInfo = ownerType.GetInnerFieldInfoOrThrow(fieldName); - var methodName = "SetInner" + fieldName; - - var method = new DynamicMethod(methodName, typeof(void), new[] { ownerType.MakeByRefType(), fieldInfo.FieldType }, ownerType, true); - var ilGenerator = method.GetILGenerator(); - - ilGenerator.Emit(OpCodes.Ldarg_0); - ilGenerator.Emit(OpCodes.Ldarg_1); - ilGenerator.Emit(OpCodes.Stfld, fieldInfo); - ilGenerator.Emit(OpCodes.Ret); - - return (TDelegate)method.CreateDelegate(typeof(TDelegate)); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubCollection.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubCollection.cs deleted file mode 100644 index d56a4f3..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubCollection.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -internal sealed class StubCollection : ICollection -{ - private readonly ICollection sourceCollection; - - internal StubCollection(List sourceCollection) - => - this.sourceCollection = sourceCollection; - - public int Count - => - sourceCollection.Count; - - public bool IsReadOnly - => - sourceCollection.IsReadOnly; - - public void Add(T item) - => - sourceCollection.Add(item); - - public void Clear() - => - sourceCollection.Clear(); - - public bool Contains(T item) - => - sourceCollection.Contains(item); - - public void CopyTo(T[] array, int arrayIndex) - => - sourceCollection.CopyTo(array, arrayIndex); - - public IEnumerator GetEnumerator() - => - sourceCollection.GetEnumerator(); - - public bool Remove(T item) - => - sourceCollection.Remove(item); - - IEnumerator IEnumerable.GetEnumerator() - => - ((IEnumerable)sourceCollection).GetEnumerator(); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubEnum.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubEnum.cs deleted file mode 100644 index fe54f46..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubEnum.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -internal enum StubEnum -{ - Default, - - Some -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubItemJson.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubItemJson.cs deleted file mode 100644 index 0d7fa9a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubItemJson.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace PrimeFuncPack.Collections.Tests; - -internal sealed record class StubItemJson -{ - public int Id { get; init; } - - public string? Name { get; init; } - - [JsonPropertyName("date")] - public DateTimeOffset? Date { get; init; } - - public StubEnum? EnumValue { get; init; } - - [JsonConverter(typeof(JsonStringEnumConverter))] - public StubEnum? EnumText { get; init; } - - [JsonIgnore] - public long HiddenValue { get; init; } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubReadOnlyCollection.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubReadOnlyCollection.cs deleted file mode 100644 index d8f9755..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubReadOnlyCollection.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -internal sealed class StubReadOnlyCollection : IReadOnlyCollection -{ - private readonly IReadOnlyCollection source; - - internal StubReadOnlyCollection(T[] source) - => - this.source = source; - - public int Count - => - source.Count; - - public IEnumerator GetEnumerator() - => - source.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() - => - ((IEnumerable)source).GetEnumerator(); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubReadOnlyList.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubReadOnlyList.cs deleted file mode 100644 index 97a43bb..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Stubs/StubReadOnlyList.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace PrimeFuncPack.Collections.Tests; - -internal sealed class StubReadOnlyList : IReadOnlyList -{ - private readonly IReadOnlyList source; - - internal StubReadOnlyList(List source) - => - this.source = source; - - public T this[int index] - => - source[index]; - - public int Count - => - source.Count; - - public IEnumerator GetEnumerator() - => - source.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() - => - ((IEnumerable)source).GetEnumerator(); -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/TestData/EqualityComparerTestSource.cs b/src/collections-flat-array/Collections.FlatArray.Tests/TestData/EqualityComparerTestSource.cs deleted file mode 100644 index 4384829..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/TestData/EqualityComparerTestSource.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Collections.Generic; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -internal static class EqualityComparerTestSource -{ - public static IEnumerable GetInt32ItemHashCodeTestData() - { - yield return new object[] - { - FlatArray.EqualityComparer.Default, - default(FlatArray), - new HashCode().ToHashCode() - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(), - default(FlatArray), - new HashCode().ToHashCode() - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(null), - default(FlatArray), - new HashCode().ToHashCode() - }; - - var array = new[] { One, MinusFifteen, Zero, PlusFifteen }.InitializeFlatArray(3); - - var defaultItemComparer = EqualityComparer.Default; - var builder = new HashCode(); - - builder.Add(defaultItemComparer.GetHashCode(One)); - builder.Add(defaultItemComparer.GetHashCode(MinusFifteen)); - builder.Add(defaultItemComparer.GetHashCode(Zero)); - - var expectedHashCode = builder.ToHashCode(); - - yield return new object[] - { - FlatArray.EqualityComparer.Default, - array, - expectedHashCode - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(), - array, - expectedHashCode - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(null), - array, - expectedHashCode - }; - } - - public static IEnumerable GetStringItemHashCodeTestData() - { - yield return new object[] - { - FlatArray.EqualityComparer.Default, - default(FlatArray), - new HashCode().ToHashCode() - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(), - default(FlatArray), - new HashCode().ToHashCode() - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(null), - default(FlatArray), - new HashCode().ToHashCode() - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(StringComparer.InvariantCultureIgnoreCase), - default(FlatArray), - new HashCode().ToHashCode() - }; - - var firstArray = new[] { SomeString, null, EmptyString, WhiteSpaceString, TabString, AnotherString }.InitializeFlatArray(4); - - var defaultItemComparer = EqualityComparer.Default; - var firstBuilder = new HashCode(); - - firstBuilder.Add(defaultItemComparer.GetHashCode(SomeString)); - firstBuilder.Add(0); - firstBuilder.Add(defaultItemComparer.GetHashCode(EmptyString)); - firstBuilder.Add(defaultItemComparer.GetHashCode(WhiteSpaceString)); - - var firstExpectedHashCode = firstBuilder.ToHashCode(); - - yield return new object[] - { - FlatArray.EqualityComparer.Default, - firstArray, - firstExpectedHashCode - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(), - firstArray, - firstExpectedHashCode - }; - - yield return new object[] - { - FlatArray.EqualityComparer.Create(null), - firstArray, - firstExpectedHashCode - }; - - var secondArray = new[] { AnotherString, SomeString, null, LowerAnotherString }.InitializeFlatArray(3); - - var secondItemComparer = StringComparer.InvariantCultureIgnoreCase; - var secondBuilder = new HashCode(); - - secondBuilder.Add(secondItemComparer.GetHashCode(AnotherString)); - secondBuilder.Add(secondItemComparer.GetHashCode(SomeString)); - secondBuilder.Add(0); - - var secondExpectedHashCode = secondBuilder.ToHashCode(); - - yield return new object[] - { - FlatArray.EqualityComparer.Create(secondItemComparer), - secondArray, - secondExpectedHashCode - }; - } - - public static IEnumerable GetInt32DefaultEqualityComparerTestData() - => - new[] - { - new object[] - { - FlatArray.EqualityComparer.Default - }, - new object[] - { - FlatArray.EqualityComparer.Create() - }, - new object[] - { - FlatArray.EqualityComparer.Create(null) - } - }; - - public static IEnumerable GetStringDefaultEqualityComparerTestData() - => - new[] - { - new object[] - { - FlatArray.EqualityComparer.Default - }, - new object[] - { - FlatArray.EqualityComparer.Create() - }, - new object[] - { - FlatArray.EqualityComparer.Create(null) - } - }; - - public static IEnumerable GetIgnoreCaseStringEqualityComparerTestData() - => - new[] - { - new object[] - { - FlatArray.EqualityComparer.Create(StringComparer.InvariantCultureIgnoreCase) - } - }; -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/TestData/FlatListTestSource.cs b/src/collections-flat-array/Collections.FlatArray.Tests/TestData/FlatListTestSource.cs deleted file mode 100644 index 0294e61..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/TestData/FlatListTestSource.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -internal static class FlatListTestSource -{ - public static IEnumerable GetRecordTypeCopyToInRangeTestData() - => - new[] - { - new object[] - { - new[] - { - MinusFifteenIdNullNameRecord, - ZeroIdNullNameRecord - } - .InitializeFlatList(), - new[] - { - null, - PlusFifteenIdSomeStringNameRecord - }, - 0, - new[] - { - MinusFifteenIdNullNameRecord, - ZeroIdNullNameRecord - } - }, - new object[] - { - new[] - { - PlusFifteenIdLowerSomeStringNameRecord - } - .InitializeFlatList(), - new[] - { - MinusFifteenIdNullNameRecord, - PlusFifteenIdSomeStringNameRecord - }, - 0, - new[] - { - PlusFifteenIdLowerSomeStringNameRecord, - PlusFifteenIdSomeStringNameRecord - } - }, - new object[] - { - new[] - { - null, - ZeroIdNullNameRecord, - MinusFifteenIdSomeStringNameRecord - }.InitializeFlatList(), - new[] - { - PlusFifteenIdSomeStringNameRecord, - MinusFifteenIdNullNameRecord, - null, - new() - }, - 1, - new[] - { - PlusFifteenIdSomeStringNameRecord, - null, - ZeroIdNullNameRecord, - MinusFifteenIdSomeStringNameRecord - } - }, - new object[] - { - new[] - { - PlusFifteenIdLowerSomeStringNameRecord - }.InitializeFlatList(), - new[] - { - ZeroIdNullNameRecord, - MinusFifteenIdNullNameRecord, - PlusFifteenIdSomeStringNameRecord, - PlusFifteenIdLowerSomeStringNameRecord - }, - 1, - new[] - { - ZeroIdNullNameRecord, - PlusFifteenIdLowerSomeStringNameRecord, - PlusFifteenIdSomeStringNameRecord, - PlusFifteenIdLowerSomeStringNameRecord - } - } - }; -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/TestData/JsonSerializerTestSource.cs b/src/collections-flat-array/Collections.FlatArray.Tests/TestData/JsonSerializerTestSource.cs deleted file mode 100644 index 7aa5491..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/TestData/JsonSerializerTestSource.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace PrimeFuncPack.Collections.Tests; - -internal static class JsonSerializerTestSource -{ - public static IEnumerable GetJsonSerializerOptionsTestData() - => - new[] - { - new object?[] - { - null - }, - new object?[] - { - new JsonSerializerOptions() - }, - new object?[] - { - new JsonSerializerOptions(JsonSerializerDefaults.General) - }, - new object?[] - { - new JsonSerializerOptions(JsonSerializerDefaults.Web) - }, - new object?[] - { - new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - PropertyNameCaseInsensitive = true, - NumberHandling = JsonNumberHandling.AllowReadingFromString, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, - WriteIndented = true - } - .AddConverter(new JsonStringEnumConverter()) - } - }; - - private static JsonSerializerOptions AddConverter(this JsonSerializerOptions options, JsonConverter converter) - { - options.Converters.Add(converter); - return options; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/FlatArrayBuilderStaticTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/FlatArrayBuilderStaticTest.cs deleted file mode 100644 index 7593b91..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/FlatArrayBuilderStaticTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayBuilderStaticTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.1_16.cs deleted file mode 100644 index d70f538..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.1_16.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System.Collections.Generic; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderStaticTest -{ - [Theory] - [InlineData(null)] - [InlineData(AnotherString)] - public void FromOneItem_ExpectInnerStateIsSourceItem(string? item) - { - var actual = FlatArray.Builder.From(item); - - const int expectedLength = 1; - var expectedItems = new[] { item }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwoItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(MinusFifteenIdRefType, null); - - const int expectedLength = 2; - var expectedItems = new[] { MinusFifteenIdRefType, null }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThreeItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(SomeTextRecordStruct, default, AnotherTextRecordStruct); - - const int expectedLength = 3; - var expectedItems = new[] { SomeTextRecordStruct, default, AnotherTextRecordStruct }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(TabString, null, AnotherString, SomeString); - - const int expectedLength = 4; - var expectedItems = new[] { TabString, null, AnotherString, SomeString }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFiveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(null, 21, byte.MaxValue, 211, 55); - - const int expectedLength = 5; - var expectedItems = new byte?[] { null, 21, byte.MaxValue, 211, 55 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(decimal.MinusOne, 251.7m, null, -252, 97.86m, 751); - - const int expectedLength = 6; - var expectedItems = new decimal?[] { decimal.MinusOne, 251.7m, null, -252, 97.86m, 751 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From("One", "Two", "Three", "Four", "Five", null, "Seven"); - - const int expectedLength = 7; - var expectedItems = new[] { "One", "Two", "Three", "Four", "Five", null, "Seven" }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromEightItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - PlusFifteen, null, SomeString, decimal.MinusOne, byte.MaxValue, false, int.MinValue, AnotherString); - - const int expectedLength = 8; - - var expectedItems = new object?[] - { - PlusFifteen, null, SomeString, decimal.MinusOne, byte.MaxValue, false, int.MinValue, AnotherString - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromNineItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(long.MinValue, -891, -3781, 0, 24681, -90, -1, null, 681); - - const int expectedLength = 9; - var expectedItems = new long?[] { long.MinValue, -891, -3781, 0, 24681, -90, -1, null, 681 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, default, 27, -32, -955); - - const int expectedLength = 10; - var expectedItems = new[] { MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, default, 27, -32, -955 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromElevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - decimal.MinusOne, 8691.719m, 1361, null, 75, 682, 827, 954, decimal.MaxValue, 13289, 88); - - const int expectedLength = 11; - - var expectedItems = new decimal?[] - { - decimal.MinusOne, 8691.719m, 1361, null, 75, 682, 827, 954, decimal.MaxValue, 13289, 88 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwelveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - -75, 2155, 790, 825, 351, 541, 975601, long.MaxValue, 7891, null, 571, 622); - - const int expectedLength = 12; - - var expectedItems = new long?[] - { - -75, 2155, 790, 825, 351, 541, 975601, long.MaxValue, 7891, null, 571, 622 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThirteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75); - - const int expectedLength = 13; - - var expectedItems = new[] - { - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - 0, 2, 6, 3, 91, byte.MaxValue, 71, 5, 71, 52, null, 211, 86, 23); - - const int expectedLength = 14; - - var expectedItems = new byte?[] - { - 0, 2, 6, 3, 91, byte.MaxValue, 71, 5, 71, 52, null, 211, 86, 23 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFifteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", "Ten", "Nine", - "Eight", "Nine", "Six", "Five", "Four", "Three", "Two", "One"); - - const int expectedLength = 15; - - var expectedItems = new[] - { - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", "Ten", "Nine", - "Eight", "Nine", "Six", "Five", "Four", "Three", "Two", "One" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - decimal.MinusOne, 178.81m, 24, null, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m); - - const int expectedLength = 16; - - var expectedItems = new decimal?[] - { - decimal.MinusOne, 178.81m, 24, null, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.Span.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.Span.cs deleted file mode 100644 index 7b5bbb7..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.Span.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderStaticTest -{ - [Fact] - public void FromReadOnlySpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = default(ReadOnlySpan); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromReadOnlySpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] { PlusFifteenIdLowerSomeStringNameRecord, ZeroIdNullNameRecord, null, MinusFifteenIdNullNameRecord }; - var source = new ReadOnlySpan(sourceItems); - - var actual = FlatArray.Builder.From(source); - var expectedItems = new[] { PlusFifteenIdLowerSomeStringNameRecord, ZeroIdNullNameRecord, null, MinusFifteenIdNullNameRecord }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromSpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = default(Span); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromSpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var source = new[] { SomeString, AnotherString, EmptyString }.AsSpan(); - - var actual = FlatArray.Builder.From(source); - var expectedItems = new[] { SomeString, AnotherString, EmptyString }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromSpan_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceItems = new[] - { - PlusFifteenIdRefType, null, MinusFifteenIdRefType, ZeroIdRefType - }; - - var source = sourceItems.AsSpan(); - var actual = FlatArray.Builder.From(source); - - source[0] = new(); - - var expectedItems = new[] - { - PlusFifteenIdRefType, null, MinusFifteenIdRefType, ZeroIdRefType - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.cs deleted file mode 100644 index d3a901d..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.Builder/Test.From.cs +++ /dev/null @@ -1,216 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderStaticTest -{ - [Fact] - public void FromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - RecordType?[]? source = null; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(Zero)] - [InlineData(PlusFifteen, null, MinusFifteen, PlusFifteen)] - [InlineData(12, 15, 1, 91, 7, -95, null, 0, 5, 6, 7, 901, 98, -266, 78, 62, 21, 35, 75, 212, 51)] - public void FromArray_SourceIsNotEmpty_ExpectInnerStateIsSourceArray( - params int?[] source) - { - var coppied = source.GetCopy(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { "One", "Two", "Three" }; - var actual = FlatArray.Builder.From(sourceArray); - - sourceArray[1] = "2"; - var expectedItems = new[] { "One", "Two", "Three" }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(FlatArray); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray() - { - var source = new[] { MinusFifteenIdRefType, null, ZeroIdRefType, PlusFifteenIdRefType }.InitializeFlatArray(3); - - var actual = FlatArray.Builder.From(source); - var expectedItems = new[] { MinusFifteenIdRefType, null, ZeroIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNull_ExpectInnerStateIsDefault() - { - var source = default(FlatArray?); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - FlatArray? source = default(FlatArray); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray() - { - FlatArray? source = new[] { SomeString, AnotherString }.InitializeFlatArray(); - - var actual = FlatArray.From(source); - var expectedItems = new[] { SomeString, AnotherString }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromList_SourceIsNull_ExpectInnerStateIsDefault() - { - List? source = null; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new List(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var source = new List - { - long.MinValue, 0, null, -31 - }; - - var actual = FlatArray.Builder.From(source); - - const int expectedLength = 4; - var expectedItems = new long?[] - { - long.MinValue, 0, null, -31 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromList_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - var actual = FlatArray.Builder.From(sourceList); - - sourceList[0] = PlusFifteenIdLowerSomeStringNameRecord; - sourceList.Add(MinusFifteenIdNullNameRecord); - - var expectedItems = new[] - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(ImmutableArray); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(LowerSomeString, null, AnotherString)] - public void FromImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems( - params string?[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.ToImmutableArray(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsNull_ExpectInnerStateIsDefault() - { - ImmutableArray? source = null; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - ImmutableArray? source = new ImmutableArray();; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(One)] - [InlineData(MinusFifteen, Zero, PlusFifteen)] - public void FromNullableImmutableArray_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params int[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = sourceItems.ToImmutableArray(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Fill.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Fill.cs deleted file mode 100644 index 9e3b16a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Fill.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void Fill_SourceIsDefault_ExpectDefaultState() - { - var source = default(FlatArray.Builder); - source.Fill(); - - source.VerifyInnerState(default, default); - } - - [Fact] - public void Fill_SourceIsNotDefault_ExpectStateItemsAreDefault() - { - const int length = 2; - var source = new[] { PlusFifteenIdSomeStringNameRecord, null, ZeroIdNullNameRecord }.InitializeFlatArrayBuilder(length); - - source.Fill(); - - var expectedItems = new[] { null, null, ZeroIdNullNameRecord }; - source.VerifyInnerState(expectedItems, length); - } - - [Fact] - public void FillValue_SourceIsDefault_ExpectDefaultState() - { - var source = default(FlatArray.Builder); - source.Fill(SomeTextStructType); - - source.VerifyInnerState(default, default); - } - - [Fact] - public void FillValue_SourceIsNotDefault_ExpectStateItemsIsValue() - { - const int length = 3; - var source = new[] { SomeString, EmptyString, null, AnotherString }.InitializeFlatArrayBuilder(length); - - source.Fill(UpperSomeString); - var expectedItems = new[] { UpperSomeString, UpperSomeString, UpperSomeString, AnotherString }; - - source.VerifyInnerState(expectedItems, length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.GetEnumerator.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.GetEnumerator.cs deleted file mode 100644 index 2719cba..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.GetEnumerator.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void GetEnumerator_SourceIsDefault_ExpectEnumeratorWithDefaultState() - { - var source = default(FlatArray.Builder); - var actual = source.GetEnumerator(); - - actual.VerifyInnerState(default, default, -1); - } - - [Theory] - [InlineData(1, SomeString)] - [InlineData(4, AnotherString, UpperSomeString, EmptyString, SomeString, null, WhiteSpaceString)] - public void GetEnumerator_SourceIsNotDefault_ExpectEnumeratorWithCorrectState( - int length, params string?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatArrayBuilder(length); - var actual = source.GetEnumerator(); - - actual.VerifyInnerState(coppied, length, -1); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Indexer.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Indexer.cs deleted file mode 100644 index 807651d..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Indexer.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Theory] - [InlineData(-1)] - [InlineData(0)] - [InlineData(1)] - public void Indexer_SourceIsDefault_ExpectArgumentOutOfRangeException(int index) - { - var source = default(FlatArray.Builder); - - try - { - _ = source[index]; - } - catch (ArgumentOutOfRangeException ex) - { - Assert.Equal("index", ex.ParamName); - return; - } - - Assert.Fail("An expected ArgumentOutOfRangeException was not thrown"); - } - - [Theory] - [InlineData(0, 1, TabString)] - [InlineData(1, 2, AnotherString, SomeString, LowerSomeString)] - [InlineData(2, 3, AnotherString, AnotherString, null, SomeString)] - [InlineData(3, 4, "Zero", "One", "Two", "Three")] - public void Indexer_IndexIsInRange_ExpectItemIsFromSourceItemsByIndex( - int index, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArrayBuilder(sourceLength); - - var actual = source[index]; - var expected = sourceItems[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, 1, SomeString)] - [InlineData(1, 1, AnotherString, SomeString)] - [InlineData(5, 2, EmptyString, TabString)] - [InlineData(-1, 3, LowerSomeString, null, SomeString)] - public void Indexer_IndexIsOutOfRange_ExpectArgumentOutOfRangeException( - int index, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArrayBuilder(sourceLength); - - try - { - _ = source[index]; - } - catch (ArgumentOutOfRangeException ex) - { - Assert.Equal("index", ex.ParamName); - return; - } - - Assert.Fail("An expected ArgumentOutOfRangeException was not thrown"); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.IsEmpty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.IsEmpty.cs deleted file mode 100644 index 029052b..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.IsEmpty.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void IsEmpty_SourceIsDefault_ExpectTrue() - { - var source = default(FlatArray.Builder); - var actual = source.IsEmpty; - - Assert.True(actual); - } - - [Theory] - [InlineData(true)] - [InlineData(false, false, null, true)] - public void IsEmpty_SourceIsNotDefault_ExpectFalse( - params bool?[] sourceItems) - { - var source = sourceItems.InitializeFlatArrayBuilder(); - var actual = source.IsEmpty; - - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.IsNotEmpty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.IsNotEmpty.cs deleted file mode 100644 index 2f15504..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.IsNotEmpty.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void IsNotEmpty_SourceIsDefault_ExpectTrue() - { - var source = default(FlatArray.Builder); - var actual = source.IsNotEmpty; - - Assert.False(actual); - } - - [Theory] - [InlineData(One)] - [InlineData(MinusFifteen, null, PlusFifteen)] - public void IsNotEmpty_SourceIsNotDefault_ExpectFalse( - params int?[] sourceItems) - { - var source = sourceItems.InitializeFlatArrayBuilder(); - var actual = source.IsNotEmpty; - - Assert.True(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Length.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Length.cs deleted file mode 100644 index 1849454..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.Length.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void GetLength_SourceIsDefault_ExpectDefault() - { - var source = default(FlatArray.Builder); - - var actual = source.Length; - const int expected = default; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, SomeString)] - [InlineData(2, AnotherString, null, SomeString, EmptyString)] - [InlineData(3, null, EmptyString, AnotherString)] - public void GetLength_SourceIsNotDefault_ExpectInnerLength( - int innerLength, params string?[] innerItems) - { - var source = innerItems.InitializeFlatArrayBuilder(innerLength); - - var actual = source.Length; - var expected = innerLength; - - Assert.Equal(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.MoveToArray.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.MoveToArray.cs deleted file mode 100644 index 2b3c49a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.MoveToArray.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void MoveToArray_SourceIsDefault_ExpectArrayStateIsDefault() - { - var source = default(FlatArray.Builder); - var actual = source.MoveToArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void MoveToArray_SourceIsDefault_ExpectBuilderStateIsDefault() - { - var source = default(FlatArray.Builder); - _ = source.MoveToArray(); - - source.VerifyInnerState(default, default); - } - - [Fact] - public void MoveToArray_SourceIsNotDefault_ExpectArrayItemsAreBuilderItems() - { - const int length = 3; - - var sourceItems = new[] { PlusFifteenIdRefType, null, MinusFifteenIdRefType, ZeroIdRefType }; - var source = sourceItems.InitializeFlatArrayBuilder(length); - - var actual = source.MoveToArray(); - var expectedItems = new[] { PlusFifteenIdRefType, null, MinusFifteenIdRefType, ZeroIdRefType }; - - actual.VerifyInnerState(expectedItems, length); - } - - [Fact] - public void MoveToArray_SourceIsNotDefault_ExpectBuilderStateIsDefault() - { - var source = new[] { MinusFifteen, Zero, PlusFifteen, int.MaxValue, One }.InitializeFlatArrayBuilder(); - _ = source.MoveToArray(); - - source.VerifyInnerState(default, default); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.ToString.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.ToString.cs deleted file mode 100644 index 5a8d55e..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Builder/Builder.ToString.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void ToString_SourceIsDefault_ExpectStringContainsZeroAndTypeName() - { - var source = default(FlatArray.Builder); - var actual = source.ToString(); - - Assert.Contains("0", actual, StringComparison.InvariantCulture); - Assert.Contains("RecordType", actual, StringComparison.InvariantCulture); - } - - [Fact] - public void ToString_SourceIsNotDefault_ExpectStringContainsLengthAndTypeName() - { - var sourceItems = new[] - { - SomeString, EmptyString, null, WhiteSpaceString, AnotherString - }; - - const int length = 3; - - var source = sourceItems.InitializeFlatArrayBuilder(length); - var actual = source.ToString(); - - Assert.Contains(length.ToString(), actual, StringComparison.InvariantCulture); - Assert.Contains("String", actual, StringComparison.InvariantCulture); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Enumerator/Test.Current.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Enumerator/Test.Current.cs deleted file mode 100644 index f13bd5c..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Enumerator/Test.Current.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void Enumerator_Current_SourceIsDefault_ExpectArgumentOutOfRangeException() - { - var source = default(FlatArray.Builder.Enumerator); - - try - { - _ = source.Current; - } - catch (ArgumentOutOfRangeException) - { - return; - } - - Assert.Fail("An expected ArgumentOutOfRangeException was not thrown"); - } - - [Theory] - [InlineData(0, 1, SomeString)] - [InlineData(1, 2, EmptyString, SomeString, AnotherString)] - public void Enumerator_Current_IndexIsInRange_ExpectItemByIndex( - int index, int length, params string[] sourceItems) - { - var coppiedItems = sourceItems.GetCopy(); - var source = sourceItems.InitializeFlatArrayBuilder(length).InitializeEnumerator(index); - - var actual = source.Current; - var expected = coppiedItems[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, 1, PlusFifteen)] - [InlineData(3, 2, MinusFifteen, null, Zero, One, PlusFifteen)] - [InlineData(-1, 2, MinusOne, PlusFifteen)] - public void Enumerator_Current_IndexIsNotInRange_ExpectArgumentOutOfRangeException( - int index, int length, params int?[] sourceItems) - { - var source = sourceItems.InitializeFlatArrayBuilder(length).InitializeEnumerator(index); - - try - { - _ = source.Current; - } - catch (ArgumentOutOfRangeException) - { - return; - } - - Assert.Fail("An expected ArgumentOutOfRangeException was not thrown"); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Enumerator/Test.MoveNext.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Enumerator/Test.MoveNext.cs deleted file mode 100644 index ddd0e3c..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Enumerator/Test.MoveNext.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void Enumerator_MoveNext_SourceIsDefault_ExpectFalseAndDefaultState() - { - var source = default(FlatArray.Builder.Enumerator); - var actual = source.MoveNext(); - - Assert.False(actual); - source.VerifyInnerState(default, default, default); - } - - [Theory] - [InlineData(-1, 1, SomeString)] - [InlineData(0, 2, WhiteSpaceString, AnotherString, null)] - [InlineData(2, 5, SomeString, null, TabString, AnotherString, WhiteSpaceString)] - public void Enumerator_MoveNext_IndexIsLessThanLengthMinusOne_ExpectTrueAndNextIndex( - int index, int length, params string?[] items) - { - var coppiedItems = items.GetCopy(); - - var source = items.InitializeFlatArrayBuilder(length).InitializeEnumerator(index); - var actual = source.MoveNext(); - - Assert.True(actual); - source.VerifyInnerState(coppiedItems, length, index + 1); - } - - [Theory] - [InlineData(1, 1, true)] - [InlineData(6, 5, false, true, null, true, null, false, true)] - public void Enumerator_MoveNext_IndexIsEqualToLengthOrGreate_ExpectFalseAndIndexHasNotChanged( - int index, int length, params bool?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatArrayBuilder(length).InitializeEnumerator(index); - var actual = source.MoveNext(); - - Assert.False(actual); - source.VerifyInnerState(coppied, length, index); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equality.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equality.cs deleted file mode 100644 index b779d9d..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equality.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void Equality_LeftIsDefaultAndRightIsDefault_ExpectTrue() - { - var left = default(FlatArray.Builder); - var right = default(FlatArray.Builder); - - var actual = left == right; - Assert.True(actual); - } - - [Fact] - public void Equality_LeftLengthIsNotEqualToRightLength_ExpectFalse() - { - var items = new[] { PlusFifteenIdRefType, ZeroIdRefType, null }; - - var left = items.InitializeFlatArrayBuilder(3); - var right = items.InitializeFlatArrayBuilder(2); - - var actual = left == right; - Assert.False(actual); - } - - [Fact] - public void Equality_LeftArrayIsSameAsRightArray_ExpectTrue() - { - var items = new[] { Zero, MinusOne, PlusFifteen, int.MaxValue, MinusFifteen }; - - var left = items.InitializeFlatArrayBuilder(3); - var right = items.InitializeFlatArrayBuilder(3); - - var actual = left == right; - Assert.True(actual); - } - - [Fact] - public void Equality_LeftArrayIsNotSameAsRightArray_ExpectFalse() - { - var left = new[] { SomeTextRecordStruct, default }.InitializeFlatArrayBuilder(); - var right = new[] { SomeTextRecordStruct, default }.InitializeFlatArrayBuilder(); - - var actual = left == right; - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Object.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Object.cs deleted file mode 100644 index 161a1db..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Object.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void EqualsWithObject_SourceIsDefault_ExpectNotSupportedException() - { - var source = default(FlatArray.Builder); - - try - { - _ = source.Equals(new object()); - } - catch (NotSupportedException) - { - return; - } - - Assert.Fail("An expected NotSupportedException was not thrown"); - } - - [Fact] - public void EqualsWithObject_SourceIsNotDefault_ExpectNotSupportedException() - { - var source = new[] { SomeTextRecordStruct }.InitializeFlatArrayBuilder(); - - try - { - _ = source.Equals(new object()); - } - catch (NotSupportedException) - { - return; - } - - Assert.Fail("An expected NotSupportedException was not thrown"); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Other.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Other.cs deleted file mode 100644 index f893b06..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Other.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void EqualsWithOther_SourceIsDefaultAndOtherIsDefault_ExpectTrue() - { - var source = default(FlatArray.Builder); - var other = default(FlatArray.Builder); - - var actual = source.Equals(other); - Assert.True(actual); - } - - [Fact] - public void EqualsWithOther_SourceLengthIsNotEqualToOtherLength_ExpectFalse() - { - var items = new StructType?[] { SomeTextStructType, LowerSomeTextStructType, null }; - - var source = items.InitializeFlatArrayBuilder(2); - var other = items.InitializeFlatArrayBuilder(3); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithOther_SourceArrayIsSameAsOtherArray_ExpectTrue() - { - var items = new[] { decimal.MinusOne, decimal.MaxValue, decimal.MinusOne, default }; - - var source = items.InitializeFlatArrayBuilder(4); - var other = items.InitializeFlatArrayBuilder(4); - - var actual = source.Equals(other); - Assert.True(actual); - } - - [Fact] - public void EqualsWithOther_SourceArrayIsNotSameAsOtherArray_ExpectFalse() - { - var source = new[] { PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType }.InitializeFlatArrayBuilder(); - var other = new[] { PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType }.InitializeFlatArrayBuilder(); - - var actual = source.Equals(other); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Static.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Static.cs deleted file mode 100644 index 5883ddf..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Equals.Static.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void EqualsStatic_LeftIsDefaultAndRightIsDefault_ExpectTrue() - { - var left = default(FlatArray.Builder); - var right = default(FlatArray.Builder); - - var actual = FlatArray.Builder.Equals(left, right); - Assert.True(actual); - } - - [Fact] - public void EqualsStatic_LeftLengthIsNotEqualToRightLength_ExpectFalse() - { - var items = new[] { MinusFifteen, Zero, PlusFifteen, One, MinusOne, int.MinValue }; - - var left = items.InitializeFlatArrayBuilder(5); - var right = items.InitializeFlatArrayBuilder(6); - - var actual = FlatArray.Builder.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void EqualsStatic_LeftArrayIsSameAsRightArray_ExpectTrue() - { - var items = new[] { SomeTextRecordStruct, UpperAnotherTextRecordStruct, AnotherTextRecordStruct }; - - var left = items.InitializeFlatArrayBuilder(2); - var right = items.InitializeFlatArrayBuilder(2); - - var actual = FlatArray.Builder.Equals(left, right); - Assert.True(actual); - } - - [Fact] - public void EqualsStatic_LeftArrayIsNotSameAsRightArray_ExpectFalse() - { - var left = new[] { PlusFifteenIdLowerSomeStringNameRecord, ZeroIdNullNameRecord, null }.InitializeFlatArrayBuilder(); - var right = new[] { PlusFifteenIdLowerSomeStringNameRecord, ZeroIdNullNameRecord, null }.InitializeFlatArrayBuilder(); - - var actual = FlatArray.Builder.Equals(left, right); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.GetHashCode.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.GetHashCode.cs deleted file mode 100644 index 1a6da2a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.GetHashCode.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void GetHashCode_SourceIsDefault_ExpectNotSupportedException() - { - var source = default(FlatArray.Builder); - - try - { - _ = source.GetHashCode(); - } - catch (NotSupportedException) - { - return; - } - - Assert.Fail("An expected NotSupportedException was not thrown"); - } - - [Fact] - public void GetHashCode_SourceIsNotDefault_ExpectNotSupportedException() - { - var source = new[] { PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType }.InitializeFlatArrayBuilder(2); - - try - { - _ = source.GetHashCode(); - } - catch (NotSupportedException) - { - return; - } - - Assert.Fail("An expected NotSupportedException was not thrown"); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Inequality.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Inequality.cs deleted file mode 100644 index a0a4ed0..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Equality/Equality.Inequality.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void Inequality_LeftIsDefaultAndRightIsDefault_ExpectFalse() - { - var left = default(FlatArray.Builder); - var right = default(FlatArray.Builder); - - var actual = left != right; - Assert.False(actual); - } - - [Fact] - public void Inequality_LeftLengthIsNotEqualToRightLength_ExpectTrue() - { - var items = new[] { One, int.MinValue, Zero, PlusFifteen, One, MinusFifteen, int.MaxValue }; - - var left = items.InitializeFlatArrayBuilder(4); - var right = items.InitializeFlatArrayBuilder(5); - - var actual = left != right; - Assert.True(actual); - } - - [Fact] - public void Inequality_LeftArrayIsSameAsRightArray_ExpectFalse() - { - var items = new RecordStruct?[] { SomeTextRecordStruct, null, AnotherTextRecordStruct }; - - var left = items.InitializeFlatArrayBuilder(2); - var right = items.InitializeFlatArrayBuilder(2); - - var actual = left != right; - Assert.False(actual); - } - - [Fact] - public void Inequality_LeftArrayIsNotSameAsRightArray_ExpectTrue() - { - var left = new[] { SomeString, AnotherString, TabString, WhiteSpaceString }.InitializeFlatArrayBuilder(); - var right = new[] { SomeString, AnotherString, TabString, WhiteSpaceString }.InitializeFlatArrayBuilder(); - - var actual = left != right; - Assert.True(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.Constructor.1_16.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.Constructor.1_16.cs deleted file mode 100644 index 8bd9511..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.Constructor.1_16.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Theory] - [InlineData(null)] - [InlineData(true)] - public void ConstructFromOneItem_ExpectInnerStateIsSourceItem(bool? item) - { - var actual = new FlatArray.Builder(item); - - const int expectedLength = 1; - var expectedItems = new[] { item }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromTwoItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder(null, SomeTextStructType); - - const int expectedLength = 2; - var expectedItems = new StructType?[] { null, SomeTextStructType }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromThreeItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder(SomeString, AnotherString, string.Empty); - - const int expectedLength = 3; - var expectedItems = new[] { SomeString, AnotherString, string.Empty }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFourItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder(null, PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType); - - const int expectedLength = 4; - var expectedItems = new[] { null, PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFiveItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder(51, 2801, -71, int.MaxValue, 67); - - const int expectedLength = 5; - var expectedItems = new[] { 51, 2801, -71, int.MaxValue, 67 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromSixItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder("1:One", "2:Two", "3:Three", "4:Four", "5:Five", null); - - const int expectedLength = 6; - var expectedItems = new[] { "1:One", "2:Two", "3:Three", "4:Four", "5:Five", null }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromSevenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - null, 1478, -791, double.PositiveInfinity, 78.891, 9, double.Epsilon); - - const int expectedLength = 7; - - var expectedItems = new double?[] - { - null, 1478, -791, double.PositiveInfinity, 78.891, 9, double.Epsilon - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromEightItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - 189165, 41, 6, 0, 891, 2546, 64, 147); - - const int expectedLength = 8; - - var expectedItems = new uint[] - { - 189165, 41, 6, 0, 891, 2546, 64, 147 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromNineItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - SomeString, LowerAnotherString, null, EmptyString, AnotherString, - UpperSomeString, WhiteSpaceString, UpperAnotherString, TabString); - - const int expectedLength = 9; - - var expectedItems = new[] - { - SomeString, LowerAnotherString, null, EmptyString, AnotherString, - UpperSomeString, WhiteSpaceString, UpperAnotherString, TabString - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromTenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - 127, 95, 221, 54, 7, 86, 74, 1, 82, 17); - - const int expectedLength = 10; - - var expectedItems = new byte[] - { - 127, 95, 221, 54, 7, 86, 74, 1, 82, 17 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromElevenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - "Eleventh", "Tenth", "Ninth", "Eighth", "Seventh", null, - "Fifth", "Fourth", "Third", "Second", "First"); - - const int expectedLength = 11; - - var expectedItems = new[] - { - "Eleventh", "Tenth", "Ninth", "Eighth", "Seventh", null, - "Fifth", "Fourth", "Third", "Second", "First" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromTwelveItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - 68, 982, 75, 30121, 5007, int.MinValue, - 871, Zero, 551, -3092, 27, -893); - - const int expectedLength = 12; - - var expectedItems = new[] - { - 68, 982, 75, 30121, 5007, int.MinValue, - 871, Zero, 551, -3092, 27, -893 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromThirteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - "First", "Second", "Third", "Fourth", "Fifth", "Sixth", string.Empty, - "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth", "Thirteenth"); - - const int expectedLength = 13; - - var expectedItems = new[] - { - "First", "Second", "Third", "Fourth", "Fifth", "Sixth", string.Empty, - "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth", "Thirteenth" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFourteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - -205, long.MaxValue, 78, 9717253, 27, -125, 51, - long.MinValue, 11, 27, 95123, Zero, 82, 61); - - const int expectedLength = 14; - - var expectedItems = new[] - { - -205, long.MaxValue, 78, 9717253, 27, -125, 51, - long.MinValue, 11, 27, 95123, Zero, 82, 61 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFifteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - 71, 22, 789, int.MinValue, 157, PlusFifteen, 102937, -91, - 78612, -21, -188, Zero, int.MaxValue, PlusFifteen, 51); - - const int expectedLength = 15; - - var expectedItems = new[] - { - 71, 22, 789, int.MinValue, 157, PlusFifteen, 102937, -91, - 78612, -21, -188, Zero, int.MaxValue, PlusFifteen, 51 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromSixteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray.Builder( - "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", - "Nine", "Ten", "Eleven", "Twelve", string.Empty, "Fourteen", "Fifteen", "Sixteen"); - - const int expectedLength = 16; - - var expectedItems = new[] - { - "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", - "Nine", "Ten", "Eleven", "Twelve", string.Empty, "Fourteen", "Fifteen", "Sixteen" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.Constructor.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.Constructor.cs deleted file mode 100644 index d1734d4..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.Constructor.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void ConstructFromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - RecordType[]? source = null; - var actual = new FlatArray.Builder(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ConstructFromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = new FlatArray.Builder(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(AnotherString)] - [InlineData(SomeString, LowerAnotherString, EmptyString, null, UpperSomeString)] - [InlineData("01", "02", "03", "04", "05", "06", "07", null, "09", "10", "11", "12", "13", "14", TabString, "16", "17")] - public void ConstructFromArray_SourceIsNotEmpty_ExpectInnerStateIsSource( - params string?[] source) - { - var coppied = source.GetCopy(); - var actual = new FlatArray.Builder(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void ConstructFromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { PlusFifteenIdRefType, ZeroIdRefType }; - var actual = new FlatArray.Builder(sourceArray); - - sourceArray[0] = MinusFifteenIdRefType; - var expectedItems = new[] { PlusFifteenIdRefType, ZeroIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.1_16.cs deleted file mode 100644 index f0d1d49..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.1_16.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Theory] - [InlineData(null)] - [InlineData(MinusFifteen)] - public void FromOneItem_ExpectInnerStateIsSourceItem(int? item) - { - var actual = FlatArray.Builder.From(item); - - const int expectedLength = 1; - var expectedItems = new[] { item }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwoItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(ZeroIdRefType, null); - - const int expectedLength = 2; - var expectedItems = new[] { ZeroIdRefType, null }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThreeItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(SomeTextStructType, default, LowerSomeTextStructType); - - const int expectedLength = 3; - var expectedItems = new[] { SomeTextStructType, default, LowerSomeTextStructType }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From(SomeString, null, AnotherString, EmptyString); - - const int expectedLength = 4; - var expectedItems = new[] { SomeString, null, AnotherString, EmptyString }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFiveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - new(2021, 11, 05), new(2022, 07, 15), new(2019, 02, 14), new(1997, 12, 01), new(2015, 03, 01)); - - const int expectedLength = 5; - - var expectedItems = new DateOnly[] - { - new(2021, 11, 05), new(2022, 07, 15), new(2019, 02, 14), new(1997, 12, 01), new(2015, 03, 01) - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - -89, -35, 57, 0, 789, 56341); - - const int expectedLength = 6; - - var expectedItems = new long[] - { - -89, -35, 57, 0, 789, 56341 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - null, SomeString, MinusFifteenIdRefType, MinusFifteen, false, LowerSomeTextStructType, byte.MaxValue); - - const int expectedLength = 7; - - var expectedItems = new object?[] - { - null, SomeString, MinusFifteenIdRefType, MinusFifteen, false, LowerSomeTextStructType, byte.MaxValue - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromEightItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - -751.81m, decimal.MinusOne, null, 178, -7531, -69, 275, 935); - - const int expectedLength = 8; - - var expectedItems = new decimal?[] - { - -751.81m, decimal.MinusOne, null, 178, -7531, -69, 275, 935 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromNineItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - 264, -891, long.MaxValue, 0, 24681, -90, -1, 755, 681); - - const int expectedLength = 9; - - var expectedItems = new long?[] - { - 264, -891, long.MaxValue, 0, 24681, -90, -1, 755, 681 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, 17892, null, -32, -955); - - const int expectedLength = 10; - - var expectedItems = new int?[] - { - MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, 17892, null, -32, -955 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromElevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - decimal.MinusOne, 8691.719m, 1361, -789018, 75, 682, - 827, 954, decimal.MaxValue, 13289, 88); - - const int expectedLength = 11; - - var expectedItems = new[] - { - decimal.MinusOne, 8691.719m, 1361, -789018, 75, 682, - 827, 954, decimal.MaxValue, 13289, 88 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwelveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - -75, 2155, 790, 825, 351, 541, - 975601, long.MaxValue, 7891, null, 571, 622); - - const int expectedLength = 12; - - var expectedItems = new long?[] - { - -75, 2155, 790, 825, 351, 541, - 975601, long.MaxValue, 7891, null, 571, 622 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThirteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, - -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75); - - const int expectedLength = 13; - - var expectedItems = new[] - { - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, - -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - 0, 2, 6, 3, 91, byte.MaxValue, 71, - 5, 71, 52, 122, 211, 86, 23); - - const int expectedLength = 14; - - var expectedItems = new byte[] - { - 0, 2, 6, 3, 91, byte.MaxValue, 71, - 5, 71, 52, 122, 211, 86, 23 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFifteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", string.Empty, "Nine", - "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One"); - - const int expectedLength = 15; - - var expectedItems = new[] - { - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", string.Empty, "Nine", - "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.Builder.From( - decimal.MinusOne, 178.81m, 24, -75195.71m, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m); - - const int expectedLength = 16; - - var expectedItems = new[] - { - decimal.MinusOne, 178.81m, 24, -75195.71m, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.Span.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.Span.cs deleted file mode 100644 index 7eee45d..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.Span.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void FromReadOnlySpan_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(ReadOnlySpan); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromReadOnlySpan_SourceIsNotDefault_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] - { - SomeTextRecordStruct, UpperAnotherTextRecordStruct, default - }; - - var source = new ReadOnlySpan(sourceItems); - var actual = FlatArray.Builder.From(source); - - var expectedItems = new[] - { - SomeTextRecordStruct, UpperAnotherTextRecordStruct, default - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromSpan_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(Span); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromSpan_SourceIsNotDefault_ExpectInnerStateAreSourceItems() - { - var source = new[] { MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord }.AsSpan(); - var actual = FlatArray.Builder.From(source); - - var expectedItems = new[] - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromSpan_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var source = new[] { SomeString, null, EmptyString, UpperSomeString, AnotherString }.AsSpan(); - var actual = FlatArray.Builder.From(source); - - source[3] = TabString; - - var expectedItems = new[] { SomeString, null, EmptyString, UpperSomeString, AnotherString }; - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.cs deleted file mode 100644 index 2d138cd..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.From.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Fact] - public void FromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - StructType[]? source = null; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(Zero)] - [InlineData(PlusFifteen, Zero, MinusFifteen, PlusFifteen)] - [InlineData(12, 15, 1, 91, 7, -95, 975, 0, 5, 6, 7, 901, 98, -266, 78, 62, 21, 35, 75, 212, 51)] - public void FromArray_SourceIsNotEmpty_ExpectInnerStateIsSourceArray( - params int[] source) - { - var coppied = source.GetCopy(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { "One", "Two", "Three" }; - var actual = FlatArray.Builder.From(sourceArray); - - sourceArray[0] = "2"; - var expectedItems = new[] { "One", "Two", "Three" }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(FlatArray); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString, AnotherString)] - [InlineData(LowerSomeString, null, SomeString, EmptyString, WhiteSpaceString)] - public void FromFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray( - params string?[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.InitializeFlatArray(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNull_ExpectInnerStateIsDefault() - { - var source = default(FlatArray?); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - FlatArray? source = default(FlatArray); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray() - { - FlatArray? source = new bool?[] { false, null, true }.InitializeFlatArray(2); - - var actual = FlatArray.Builder.From(source); - var expectedItems = new bool?[] { false, null }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromList_SourceIsNull_ExpectInnerStateIsDefault() - { - List? source = null; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new List(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var source = new List - { - SomeTextRecordStruct, null, AnotherTextRecordStruct - }; - - var actual = FlatArray.Builder.From(source); - - const int expectedLength = 3; - var expectedItems = new RecordStruct?[] - { - SomeTextRecordStruct, null, AnotherTextRecordStruct - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromList_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - var actual = FlatArray.Builder.From(sourceList); - - sourceList[0] = PlusFifteenIdLowerSomeStringNameRecord; - sourceList.Add(MinusFifteenIdNullNameRecord); - - const int expectedLength = 3; - var expectedItems = new[] - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(ImmutableArray); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(LowerSomeString, null, AnotherString)] - public void FromImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems( - params string?[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.ToImmutableArray(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsNull_ExpectInnerStateIsDefault() - { - ImmutableArray? source = null; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - ImmutableArray? source = new ImmutableArray();; - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(PlusFifteen)] - [InlineData(null, MinusFifteen, Zero)] - public void FromNullableImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems( - params int?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = sourceItems.ToImmutableArray(); - var actual = FlatArray.Builder.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.OfLength.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.OfLength.cs deleted file mode 100644 index adc8b25..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/Factory/Factory.OfLength.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayBuilderTest -{ - [Theory] - [InlineData(-5)] - [InlineData(-1)] - public void OfLength_LengthIsLessThanZero_ExpectArgumentOutOfRangeException( - int length) - { - var ex = Assert.Throws(Test); - Assert.Equal("length", ex.ParamName); - - void Test() - => - _ = FlatArray.Builder.OfLength(length); - } - - [Fact] - public void OfLength_LengthIsZero_ExpectDefaultState() - { - var actual = FlatArray.Builder.OfLength(0); - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(1)] - [InlineData(15)] - public void OfLength_LengthIsMoreThanZero_ExpectDefaultValuesOfSourceLengthState( - int length) - { - var actual = FlatArray.Builder.OfLength(length); - var expectedItems = new RefType?[length]; - - actual.VerifyInnerState(expectedItems, length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/FlatArrayBuilderTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/FlatArrayBuilderTest.cs deleted file mode 100644 index 99a2592..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Builder/FlatArrayBuilderTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayBuilderTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/FlatArrayEqualityComparerTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/FlatArrayEqualityComparerTest.cs deleted file mode 100644 index 04d898f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/FlatArrayEqualityComparerTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayEqualityComparerTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/Test.Equals.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/Test.Equals.cs deleted file mode 100644 index eb98d11..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/Test.Equals.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Collections.Generic; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; -using static PrimeFuncPack.Collections.Tests.EqualityComparerTestSource; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayEqualityComparerTest -{ - [Theory] - [MemberData(nameof(GetStringDefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - [MemberData(nameof(GetIgnoreCaseStringEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_LeftIsDefaultAndRightIsDefault_ExpectTrue( - FlatArray.EqualityComparer source) - { - var left = default(FlatArray); - var right = default(FlatArray); - - var actual = source.Equals(left, right); - Assert.True(actual); - } - - [Theory] - [MemberData(nameof(GetInt32DefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_LeftIsDefaultAndRightIsNotDefault_ExpectFalse( - FlatArray.EqualityComparer source) - { - var left = default(FlatArray); - var right = new[] { PlusFifteen }.InitializeFlatArray(); - - var actual = source.Equals(left, right); - Assert.False(actual); - } - - [Theory] - [MemberData(nameof(GetStringDefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - [MemberData(nameof(GetIgnoreCaseStringEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_LeftIsNotDefaultAndRightIsDefault_ExpectFalse( - FlatArray.EqualityComparer source) - { - var left = new string?[] { null }.InitializeFlatArray(); - var right = default(FlatArray); - - var actual = source.Equals(left, right); - Assert.False(actual); - } - - [Theory] - [MemberData(nameof(GetInt32DefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_LeftLengthIsNotEqualToRightLength_ExpectFalse( - FlatArray.EqualityComparer source) - { - var items = new[] { MinusFifteen, int.MinValue, Zero, One, PlusFifteen, int.MinValue }; - - var left = items.InitializeFlatArray(5); - var right = items.InitializeFlatArray(4); - - var actual = source.Equals(left, right); - Assert.False(actual); - } - - [Theory] - [MemberData(nameof(GetStringDefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_ComparerIsDefault_LeftItemsAreEqualToRightItems_ExpectTrue( - FlatArray.EqualityComparer source) - { - var left = new[] { null, EmptyString, SomeString }.InitializeFlatArray(); - var right = new[] { null, EmptyString, SomeString }.InitializeFlatArray(); - - var actual = source.Equals(left, right); - Assert.True(actual); - } - - [Theory] - [MemberData(nameof(GetIgnoreCaseStringEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_ComparerIsIgnoreCaseComparer_LeftItemsAreEqualWithoutCaseToRightItems_ExpectTrue( - FlatArray.EqualityComparer source) - { - var left = new[] { null, EmptyString, LowerSomeString }.InitializeFlatArray(); - var right = new[] { null, EmptyString, SomeString }.InitializeFlatArray(); - - var actual = source.Equals(left, right); - Assert.True(actual); - } - - [Theory] - [MemberData(nameof(GetStringDefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void Equals_LeftItemsAreNotEqualToRightItems_ExpectFalse( - FlatArray.EqualityComparer source) - { - var left = new[] { null, EmptyString, LowerSomeString }.InitializeFlatArray(); - var right = new[] { null, EmptyString, SomeString }.InitializeFlatArray(); - - var actual = source.Equals(left, right); - Assert.False(actual); - } - - [Theory] - [MemberData(nameof(GetInt32DefaultEqualityComparerTestData), MemberType = typeof(EqualityComparerTestSource))] - public void DefaultItemComparer_Equals_LeftItemsOrderAreNotSameAsRightItemsOrder_ExpectFalse( - FlatArray.EqualityComparer source) - { - var left = new[] { PlusFifteen, Zero, MinusFifteen }.InitializeFlatArray(); - var right = new[] { PlusFifteen, MinusFifteen, Zero }.InitializeFlatArray(); - - var actual = source.Equals(left, right); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/Test.GetHashCode.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/Test.GetHashCode.cs deleted file mode 100644 index 64537ae..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.EqualityComparer/Test.GetHashCode.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using Xunit; -using static PrimeFuncPack.Collections.Tests.EqualityComparerTestSource; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayEqualityComparerTest -{ - [Theory] - [MemberData(nameof(GetInt32ItemHashCodeTestData), MemberType = typeof(EqualityComparerTestSource))] - public void GetHashCode_ItemTypeIsInt32_ExpectCorrectHashCode( - FlatArray.EqualityComparer source, FlatArray array, int expected) - { - var actual = source.GetHashCode(array); - Assert.Equal(expected, actual); - } - - [Theory] - [MemberData(nameof(GetStringItemHashCodeTestData), MemberType = typeof(EqualityComparerTestSource))] - public void GetHashCode_ItemTypeIsString_ExpectCorrectHashCode( - FlatArray.EqualityComparer source, FlatArray array, int expected) - { - var actual = source.GetHashCode(array); - Assert.Equal(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/FlatArrayFlatListTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/FlatArrayFlatListTest.cs deleted file mode 100644 index 1e475d1..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/FlatArrayFlatListTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayFlatListTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Current.Object.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Current.Object.cs deleted file mode 100644 index 247b81c..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Current.Object.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(0, 1, PlusFifteen)] - [InlineData(1, 3, null, Zero, One)] - [InlineData(4, 5, MinusFifteen, MinusOne, One, Zero, PlusFifteen)] - public void InnerEnumerator_CurrentObject_IndexIsInRange_ExpectItemByIndex( - int index, int sourceLength, params int?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - var source = (IEnumerator)sourceItems.InitializeFlatListEnumerator(sourceLength, index); - - var actual = source.Current; - var expected = coppied[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(-1, 0)] - [InlineData(1, 1, EmptyString)] - [InlineData(3, 2, SomeString, null, EmptyString, WhiteSpaceString)] - [InlineData(-1, 3, UpperSomeString, SomeString, TabString)] - public void InnerEnumerator_CurrentObject_IndexIsNotInRange_ExpectInvalidOperationException( - int index, int sourceLength, params string?[] sourceItems) - { - var source = (IEnumerator)sourceItems.InitializeFlatListEnumerator(sourceLength, index); - _ = Assert.Throws(Test); - - void Test() - => - _ = source.Current; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Current.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Current.cs deleted file mode 100644 index aa45293..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Current.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(0, 1, SomeString)] - [InlineData(1, 2, LowerSomeString, AnotherString, SomeString)] - [InlineData(3, 5, "One", "Two", null, "Four", "Five")] - public void InnerEnumerator_Current_IndexIsInRange_ExpectItemByIndex( - int index, int sourceLength, params string?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - var source = sourceItems.InitializeFlatListEnumerator(sourceLength, index); - - var actual = source.Current; - var expected = coppied[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(-1, 0)] - [InlineData(1, 1, PlusFifteen, MinusFifteen)] - [InlineData(3, 2, null, MinusFifteen, Zero)] - [InlineData(-1, 3, MinusOne, One, PlusFifteen)] - public void InnerEnumerator_Current_IndexIsNotInRange_ExpectInvalidOperationException( - int index, int sourceLength, params int?[] sourceItems) - { - var source = sourceItems.InitializeFlatListEnumerator(sourceLength, index); - _ = Assert.Throws(Test); - - void Test() - => - _ = source.Current; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Dispose.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Dispose.cs deleted file mode 100644 index 730a3cb..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Dispose.cs +++ /dev/null @@ -1,20 +0,0 @@ -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void InnerEnumerator_Dispose_ExpectStateHasNotChanged() - { - var sourceItems = new RecordStruct?[] { SomeTextRecordStruct, AnotherTextRecordStruct, null, UpperSomeTextRecordStruct }; - var source = sourceItems.InitializeFlatListEnumerator(3, 1); - - source.Dispose(); - - var expectedItems = new RecordStruct?[] { SomeTextRecordStruct, AnotherTextRecordStruct, null, UpperSomeTextRecordStruct }; - source.VerifyInnerFlatListEnumeratorState(expectedItems, 3, 1); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.MoveNext.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.MoveNext.cs deleted file mode 100644 index 9644d68..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.MoveNext.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(-1, 1, true)] - [InlineData(0, 2, false, true, true)] - [InlineData(2, 5, null, false, null, true, false, true)] - public void InnerEnumerator_MoveNext_IndexIsLessThanLengthMinusOne_ExpectTrueAndNextIndex( - int index, int length, params bool?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatListEnumerator(length, index); - var actual = source.MoveNext(); - - Assert.True(actual); - source.VerifyInnerFlatListEnumeratorState(coppied, length, index + 1); - } - - [Theory] - [InlineData(-1, 0)] - [InlineData(0, 1, SomeString)] - [InlineData(1, 2, EmptyString, AnotherString, SomeString)] - [InlineData(3, 4, SomeString, null, AnotherString, EmptyString)] - public void InnerEnumerator_MoveNext_IndexIsEqualToLengthMinusOne_ExpectFalseAndIndexIsEqualToLength( - int index, int length, params string?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatListEnumerator(length, index); - var actual = source.MoveNext(); - - Assert.False(actual); - source.VerifyInnerFlatListEnumeratorState(coppied, length, length); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(1, 1, One)] - [InlineData(3, 2, PlusFifteen, Zero)] - [InlineData(4, 4, MinusFifteen, One, PlusFifteen, null, MinusOne)] - public void InnerEnumerator_MoveNext_IndexIsEqualToLengthOrGreate_ExpectFalseAndIndexHasNotChanged( - int index, int length, params int?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatListEnumerator(length, index); - var actual = source.MoveNext(); - - Assert.False(actual); - source.VerifyInnerFlatListEnumeratorState(coppied, length, index); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Reset.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Reset.cs deleted file mode 100644 index 62ffea0..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/InnerEnumerator/InnerEnumerator.Reset.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void InnerEnumerator_Reset_ExpectIndexIsMinuOne() - { - var sourceItems = new[] { MinusFifteenIdRefType, null, PlusFifteenIdRefType }; - var source = sourceItems.InitializeFlatListEnumerator(2, 1); - - source.Reset(); - - var expectedItems = new[] { MinusFifteenIdRefType, null, PlusFifteenIdRefType }; - source.VerifyInnerFlatListEnumeratorState(expectedItems, 2, -1); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Contains.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Contains.cs deleted file mode 100644 index 5c5c4bc..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Contains.cs +++ /dev/null @@ -1,44 +0,0 @@ -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void Contains_SourceIsEmpty_ExpectFalse() - { - var source = TestHelper.CreateEmptyFlatList(); - var actual = source.Contains(MinusFifteenIdRefType); - - Assert.False(actual); - } - - [Theory] - [InlineData(SomeString, 1, SomeString)] - [InlineData(null, 2, TabString, null, EmptyString)] - [InlineData(SomeString, 3, LowerSomeString, AnotherString, SomeString, EmptyString)] - [InlineData(AnotherString, 5, SomeString, AnotherString, null, EmptyString, TabString)] - public void Contains_SourceItemContainsItem_ExpectTrue( - string? item, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatList(sourceLength); - var actual = source.Contains(item); - - Assert.True(actual); - } - - [Theory] - [InlineData(TabString, 1, EmptyString)] - [InlineData(SomeString, 1, TabString, SomeString)] - [InlineData(null, 3, SomeString, AnotherString, EmptyString)] - public void Contains_SourceItemsDoesNotContainItem_ExpectFalse( - string? item, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatList(sourceLength); - var actual = source.Contains(item); - - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.CopyTo.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.CopyTo.cs deleted file mode 100644 index 5c1bf89..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.CopyTo.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; -using static PrimeFuncPack.Collections.Tests.FlatListTestSource; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(-1)] - [InlineData(0)] - [InlineData(1)] - public void CopyTo_SourceIsEmptyAndArrayIsNull_ExpectArgumentNullException( - int arrayIndex) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.CopyTo(null!, arrayIndex); - } - - [Theory] - [InlineData(0)] - [InlineData(0, SomeString, null)] - [InlineData(1, EmptyString, SomeString)] - [InlineData(3, EmptyString, SomeString, null)] - public void CopyTo_SourceIsEmptyAndArrayIndexIsNotLessThanZero_ExpectArrayHasNotChanged( - int arrayIndex, params string?[] array) - { - var source = TestHelper.CreateEmptyFlatList(); - var coppied = array.GetCopy(); - - source.CopyTo(array, arrayIndex); - Assert.Equal(coppied, array); - } - - [Theory] - [InlineData(-1)] - [InlineData(-5, SomeString, AnotherString)] - public void CopyTo_SourceIsEmptyAndArrayIndexIsLessThanZero_ExpectArgumentOutOfRangeException( - int arrayIndex, params string?[] array) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.CopyTo(array, arrayIndex); - } - - [Theory] - [InlineData(1)] - [InlineData(4, AnotherString, EmptyString, SomeString)] - public void CopyTo_SourceIsEmptyAndArrayIndexIsGreaterThanArrayLength_ExpectArgumentException( - int arrayIndex, params string?[] array) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.CopyTo(array, arrayIndex); - } - - [Theory] - [InlineData(-1)] - [InlineData(0)] - [InlineData(1)] - public void CopyTo_SourceIsNotEmptyAndArrayIsNull_ExpectArgumentNullException( - int arrayIndex) - { - var source = new[] { PlusFifteenIdRefType }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.CopyTo(null!, arrayIndex); - } - - [Theory] - [MemberData(nameof(GetRecordTypeCopyToInRangeTestData), MemberType = typeof(FlatListTestSource))] - public void CopyTo_SourceIsNotEmptyAndArrayIndexIsInRange_ExpectCorrectArray( - IList source, RecordType?[] array, int arrayIndex, RecordType?[] expected) - { - source.CopyTo(array, arrayIndex); - Assert.Equal(expected, array); - } - - [Theory] - [InlineData(-1)] - [InlineData(-5, false, true)] - public void CopyTo_SourceIsNotEmptyAndArrayIndexIsLessThanZero_ExpectArgumentOutOfRangeException( - int arrayIndex, params bool[] array) - { - var source = new[] { true }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.CopyTo(array, arrayIndex); - } - - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(4, null, PlusFifteen, MinusFifteen, Zero)] - [InlineData(5, null, PlusFifteen, MinusFifteen, Zero)] - public void CopyTo_SourceIsNotEmptyAndArrayLengthIsNotEnough_ExpectArgumentException( - int arrayIndex, params int?[] array) - { - var source = new int?[] { One }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.CopyTo(array, arrayIndex); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Count.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Count.cs deleted file mode 100644 index 7bb6e5f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Count.cs +++ /dev/null @@ -1,34 +0,0 @@ -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void Count_SourceIsEmpty_ExpectDefault() - { - var source = TestHelper.CreateEmptyFlatList(); - - var actual = source.Count; - const int expected = default; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, SomeString)] - [InlineData(2, null, SomeString, TabString)] - [InlineData(3, null, EmptyString, AnotherString)] - public void Count_SourceIsNotEmpty_ExpectInnerLength( - int innerLength, params string?[] innerItems) - { - var source = innerItems.InitializeFlatList(innerLength); - - var actual = source.Count; - var expected = innerLength; - - Assert.Equal(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.GetEnumerator.Generic.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.GetEnumerator.Generic.cs deleted file mode 100644 index 05ee0d1..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.GetEnumerator.Generic.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void GetEnumeratorGeneric_SourceIsEmpty_ExpectTypeIsInnerEnumeratorCorrectState() - { - var source = TestHelper.CreateEmptyFlatList(); - var actual = source.GetEnumerator(); - - actual.VerifyInnerFlatListEnumeratorState(Array.Empty(), 0, -1); - } - - [Theory] - [InlineData(1, EmptyString)] - [InlineData(2, SomeString, AnotherString, TabString, EmptyString)] - public void GetEnumeratorGeneric_SourceIsNotEmpty_ExpectInnerEnumeratorCorrectState( - int length, params string?[] items) - { - var source = items.InitializeFlatList(length); - var actual = source.GetEnumerator(); - - actual.VerifyInnerFlatListEnumeratorState(items, length, -1); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.GetEnumerator.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.GetEnumerator.cs deleted file mode 100644 index 29c015f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.GetEnumerator.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void GetEnumerator_SourceIsEmpty_ExpectInnerEnumeratorEmptyState() - { - var source = (IEnumerable)TestHelper.CreateEmptyFlatList(); - - var actual = source.GetEnumerator(); - var actualEnumerator = Assert.IsAssignableFrom>(actual); - - actualEnumerator.VerifyInnerFlatListEnumeratorState(Array.Empty(), 0, -1); - } - - [Theory] - [InlineData(1, true)] - [InlineData(3, null, false, true, true)] - public void GetEnumerator_SourceIsNotEmpty_ExpectInnerEnumeratorCorrectState( - int length, params bool?[] items) - { - var source = (IEnumerable)items.InitializeFlatList(length); - - var actual = source.GetEnumerator(); - var actualEnumerator = Assert.IsAssignableFrom>(actual); - - actualEnumerator.VerifyInnerFlatListEnumeratorState(items, length, -1); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.IndexOf.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.IndexOf.cs deleted file mode 100644 index 307b7bf..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.IndexOf.cs +++ /dev/null @@ -1,49 +0,0 @@ -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void IndexOf_SourceIsEmpty_ExpectMinusOne() - { - var source = TestHelper.CreateEmptyFlatList(); - - var actual = source.IndexOf(SomeTextStructType); - const int expected = -1; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(EmptyString, 0, 1, EmptyString)] - [InlineData(SomeString, 1, 2, LowerSomeString, SomeString, AnotherString)] - [InlineData(null, 2, 3, EmptyString, SomeString, null, AnotherString)] - [InlineData(TabString, 3, 7, AnotherString, SomeString, EmptyString, TabString, SomeString, TabString, WhiteSpaceString)] - public void IndexOf_SourceArrayContainsItem_ExpectItemIndex( - string? item, int expected, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatList(sourceLength); - var actual = source.IndexOf(item); - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(true, 1, false)] - [InlineData(false, 1, null, true)] - [InlineData(null, 3, true, false, false)] - [InlineData(true, 2, false, false, true)] - public void IndexOf_SourceArrayDoesNotContainItem_ExpectMinusOne( - bool? item, int sourceLength, params bool?[] sourceItems) - { - var source = sourceItems.InitializeFlatList(sourceLength); - - var actual = source.IndexOf(item); - const int expected = -1; - - Assert.Equal(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Indexer.Get.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Indexer.Get.cs deleted file mode 100644 index b2c7c4e..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.Indexer.Get.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void IndexerGet_SourceIsEmpty_ExpectArgumentOutOfRangeException(int index) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - _ = source[index]; - } - - [Theory] - [InlineData(0, 1, MinusFifteen)] - [InlineData(1, 2, null, PlusFifteen, One)] - [InlineData(2, 3, Zero, MinusOne, null, PlusFifteen)] - [InlineData(3, 4, PlusFifteen, null, One, MinusFifteen)] - public void IndexerGet_IndexIsInRange_ExpectItemIsFromSourceItemsByIndex( - int index, int sourceLength, params int?[] sourceItems) - { - var source = sourceItems.InitializeFlatList(sourceLength); - - var actual = source[index]; - var expected = sourceItems[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, 1, EmptyString)] - [InlineData(1, 1, SomeString, TabString)] - [InlineData(5, 2, null, UpperAnotherString)] - [InlineData(-1, 3, TabString, LowerSomeString, AnotherString)] - public void IndexerGet_IndexIsOutOfRange_ExpectArgumentOutOfRangeException( - int index, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatList(sourceLength); - var ex = Assert.Throws(Test); - - Assert.Equal("index", ex.ParamName); - - void Test() - => - _ = source[index]; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.IsReadOnly.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.IsReadOnly.cs deleted file mode 100644 index 6203df8..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/List/List.IsReadOnly.cs +++ /dev/null @@ -1,26 +0,0 @@ -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void IsReadOnly_SourceArrayIsDefault_ExpectTrue() - { - var source = TestHelper.CreateEmptyFlatList(); - var actual = source.IsReadOnly; - - Assert.True(actual); - } - - [Fact] - public void IsReadOnly_SourceArrayIsNotDefault_ExpectTrue() - { - var source = new[] { SomeTextRecordStruct, AnotherTextRecordStruct }.InitializeFlatList(); - var actual = source.IsReadOnly; - - Assert.True(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Add.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Add.cs deleted file mode 100644 index 0d8b1db..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Add.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void Add_SourceIsEmpty_ExpectNotSupportedException() - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.Add(SomeTextRecordStruct); - } - - [Fact] - public void Add_SourceIsNotEmpty_ExpectNotSupportedException() - { - var source = new[] { MinusFifteenIdRefType }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.Add(ZeroIdRefType); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Clear.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Clear.cs deleted file mode 100644 index 8745e40..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Clear.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void Clear_SourceIsEmpty_ExpectNotSupportedException() - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(source.Clear); - } - - [Fact] - public void Clear_SourceIsNotEmpty_ExpectNotSupportedException() - { - var source = new int?[] { PlusFifteen, null, MinusOne }.InitializeFlatList(); - _ = Assert.Throws(source.Clear); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Indexer.Set.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Indexer.Set.cs deleted file mode 100644 index 5c51e12..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Indexer.Set.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void IndexerSet_SourceIsEmpty_ExpectNotSupportedException(int index) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source[index] = SomeTextRecordStruct; - } - - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void IndexerSet_SourceIsNotEmpty_ExpectNotSupportedException(int index) - { - var source = new[] { PlusFifteenIdRefType, null, MinusFifteenIdRefType }.InitializeFlatList(2); - _ = Assert.Throws(Test); - - void Test() - => - source[index] = ZeroIdRefType; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Insert.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Insert.cs deleted file mode 100644 index c15baed..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Insert.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void Insert_SourceIsEmpty_ExpectNotSupportedException(int index) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.Insert(index, AnotherString); - } - - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void Insert_SourceIsNotEmpty_ExpectNotSupportedException(int index) - { - var source = new[] { decimal.One, decimal.MaxValue }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.Insert(index, decimal.Zero); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Remove.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Remove.cs deleted file mode 100644 index 52defad..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.Remove.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Fact] - public void Remove_SourceIsEmpty_ExpectNotSupportedException() - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - _ = source.Remove(MinusFifteenIdNullNameRecord); - } - - [Fact] - public void Remove_SourceIsNotEmpty_ExpectNotSupportedException() - { - var source = new[] { SomeTextStructType }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - _ = source.Remove(SomeTextStructType); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.RemoveAt.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.RemoveAt.cs deleted file mode 100644 index a3a007f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.FlatList/NotSupported/NotSupported.RemoveAt.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayFlatListTest -{ - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void RemoveAt_SourceIsEmpty_ExpectNotSupportedException(int index) - { - var source = TestHelper.CreateEmptyFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.RemoveAt(index); - } - - [Theory] - [InlineData(MinusOne)] - [InlineData(Zero)] - [InlineData(One)] - public void RemoveAt_SourceIsNotEmpty_ExpectNotSupportedException(int index) - { - var source = new[] { SomeString, EmptyString, AnotherString }.InitializeFlatList(); - _ = Assert.Throws(Test); - - void Test() - => - source.RemoveAt(index); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/FlatArrayJsonSerializerTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/FlatArrayJsonSerializerTest.cs deleted file mode 100644 index ee2582d..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/FlatArrayJsonSerializerTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayJsonSerializerTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/Test.Deserialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/Test.Deserialize.cs deleted file mode 100644 index 3dd06db..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/Test.Deserialize.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json; -using Xunit; -using static PrimeFuncPack.Collections.Tests.JsonSerializerTestSource; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayJsonSerializerTest -{ - [Theory] - [MemberData(nameof(GetJsonSerializerOptionsTestData), MemberType = typeof(JsonSerializerTestSource))] - public void Deserialize_SourceIsNullJsonValue_ExpectDefaultState( - JsonSerializerOptions? options) - { - var source = "null"; - var actual = JsonSerializer.Deserialize>(source, options); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [MemberData(nameof(GetJsonSerializerOptionsTestData), MemberType = typeof(JsonSerializerTestSource))] - public void Deserialize_SourceArrayIsEmpty_ExpectDefaultState( - JsonSerializerOptions? options) - { - var sourceArray = Array.Empty(); - var source = JsonSerializer.Serialize(sourceArray, options); - - var actual = JsonSerializer.Deserialize>(source, options); - actual.VerifyInnerState(default, default); - } - - [Theory] - [MemberData(nameof(GetJsonSerializerOptionsTestData), MemberType = typeof(JsonSerializerTestSource))] - public void Deserialize_SourceArrayIsNotEmpty_ExpectInnerItemsAreEqualToSourceArrayItems( - JsonSerializerOptions? options) - { - var sourceArray = new StubItemJson?[] - { - null, - new() - { - Id = 1, - Name = "First", - EnumValue = StubEnum.Default, - Date = new(2019, 05, 10, 07, 15, 21, TimeSpan.FromHours(3)) - }, - new() - { - Id = int.MaxValue, - EnumText = StubEnum.Default - }, - new() - { - Id = 4, - Name = "Four", - EnumText = StubEnum.Default, - EnumValue = StubEnum.Some - } - }; - - var source = JsonSerializer.Serialize(sourceArray, options); - var actual = JsonSerializer.Deserialize>(source, options); - - var expectedItems = new StubItemJson?[] - { - null, - new() - { - Id = 1, - Name = "First", - EnumValue = StubEnum.Default, - Date = new(2019, 05, 10, 07, 15, 21, TimeSpan.FromHours(3)) - }, - new() - { - Id = int.MaxValue, - EnumText = StubEnum.Default - }, - new() - { - Id = 4, - Name = "Four", - EnumText = StubEnum.Default, - EnumValue = StubEnum.Some - } - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/Test.Serialize.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/Test.Serialize.cs deleted file mode 100644 index b135c7a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T.Json/Test.Serialize.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json; -using Xunit; -using static PrimeFuncPack.Collections.Tests.JsonSerializerTestSource; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayJsonSerializerTest -{ - [Theory] - [MemberData(nameof(GetJsonSerializerOptionsTestData), MemberType = typeof(JsonSerializerTestSource))] - public void Serialize_SourceIsDefault_ExpectJsonIsEqualToEmptyArrayJson( - JsonSerializerOptions? options) - { - var source = default(FlatArray); - var actual = JsonSerializer.Serialize(source, options); - - var expectedArray = Array.Empty(); - var expected = JsonSerializer.Serialize(expectedArray, options); - - Assert.Equal(expected, actual); - } - - [Theory] - [MemberData(nameof(GetJsonSerializerOptionsTestData), MemberType = typeof(JsonSerializerTestSource))] - public void Serialize_SourceIsNotDefault_ExpectJsonIsEqualToArrayJson( - JsonSerializerOptions? options) - { - var sourceItems = new StubItemJson?[] - { - new() - { - Id = 1, - Name = "First", - EnumValue = StubEnum.Some, - Date = new(2022, 11, 01, 23, 51, 45, default), - HiddenValue = 157 - }, - null, - new() - { - Id = -3, - EnumText = StubEnum.Some, - EnumValue = StubEnum.Default - }, - new() - { - Id = 4, - Name = "Four" - } - }; - - var source = sourceItems.InitializeFlatArray(3); - var actual = JsonSerializer.Serialize(source, options); - - var expectedArray = new StubItemJson?[] - { - new() - { - Id = 1, - Name = "First", - EnumValue = StubEnum.Some, - Date = new(2022, 11, 01, 23, 51, 45, default) - }, - null, - new() - { - Id = -3, - EnumText = StubEnum.Some, - EnumValue = StubEnum.Default - } - }; - - var expected = JsonSerializer.Serialize(expectedArray, options); - - Assert.Equal(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.AsEnumerable.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.AsEnumerable.cs deleted file mode 100644 index 4825e9e..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.AsEnumerable.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void AsEnumerable_SourceIsDefault_ExpectInnerFlatListZeroLengthState() - { - var source = default(FlatArray); - var actual = source.AsEnumerable(); - - actual.VerifyInnerFlatListState(Array.Empty(), 0); - } - - [Theory] - [InlineData(1, SomeString)] - [InlineData(2, AnotherString, null, EmptyString, SomeString, TabString)] - [InlineData(5, SomeString, EmptyString, LowerAnotherString, AnotherString, UpperSomeString)] - public void AsEnumerable_SourceIsNotDefault_ExpectInnerFlatListCorrectLengthState( - int length, params string?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatArray(length); - var actual = source.AsEnumerable(); - - actual.VerifyInnerFlatListState(coppied, length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Clone.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Clone.cs deleted file mode 100644 index a75fc02..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Clone.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void Clone_SourceIsDefault_ExpectDefault() - { - var source = default(FlatArray); - - var actual = source.Clone(); - var expected = default(FlatArray); - - Assert.Equal(expected, actual); - } - - [Fact] - public void Clone_SourceIsNotDefault_ExpectClonedStateIsEqualToSourceState() - { - var sourceItems = new[] - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - var source = sourceItems.InitializeFlatArray(); - var actual = source.Clone(); - - actual.VerifyInnerState(sourceItems, sourceItems.Length); - } - - [Fact] - public void Clone_SourceLengthIsNotEqualToInnerArrayLength_ExpectClonedLengthIsEqualToSourceLength() - { - var sourceItems = new RecordStruct?[] - { - UpperSomeTextRecordStruct, null, AnotherTextRecordStruct, SomeTextRecordStruct - }; - - var source = sourceItems.InitializeFlatArray(3); - var actual = source.Clone(); - - var expectedItems = new RecordStruct?[] - { - UpperSomeTextRecordStruct, null, AnotherTextRecordStruct - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.ForEach.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.ForEach.cs deleted file mode 100644 index f97c20b..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.ForEach.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ForEach_ActionIsNull_ExpectArgumentNullException( - bool isDefault) - { - var source = isDefault ? default : new[] { SomeString, EmptyString }.InitializeFlatArray(); - - Action action = null!; - var ex = Assert.Throws(Test); - - Assert.Equal("action", ex.ParamName); - - void Test() - => - source.ForEach(action); - } - - [Fact] - public void ForEach_SourceIsDefault_ExpectActionCalledNever() - { - var source = default(FlatArray); - source.ForEach(Invoke); - - static void Invoke(string item) - => - Assert.Fail($"The action for an item '{item}' must not be invoked"); - } - - [Fact] - public void ForEach_SourceIsNotDefault_ExpectActionCalledForEachItem() - { - var sourceItems = new[] - { - PlusFifteen, One, Zero - }; - - var source = sourceItems.InitializeFlatArray(); - - var expectedQueue = new Queue(sourceItems); - source.ForEach(Invoke); - - Assert.Empty(expectedQueue); - - void Invoke(int actual) - { - var expected = expectedQueue.Dequeue(); - Assert.StrictEqual(expected, actual); - } - } - - [Fact] - public void ForEach_InnerLengthIsLessThanItemsLength_ExpectActionCalledLengthTimes() - { - var sourceItems = new[] - { - SomeString, null, AnotherString, EmptyString - }; - - var source = sourceItems.InitializeFlatArray(3); - - var expectedQueue = new Queue(); - - expectedQueue.Enqueue(SomeString); - expectedQueue.Enqueue(null); - expectedQueue.Enqueue(AnotherString); - - source.ForEach(Invoke); - - Assert.Empty(expectedQueue); - - void Invoke(string? actual) - { - var expected = expectedQueue.Dequeue(); - Assert.Equal(expected, actual); - } - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ForEachWithIndex_ActionIsNull_ExpectArgumentNullException( - bool isDefault) - { - var source = isDefault ? default : new bool?[] { true, null, false }.InitializeFlatArray(); - - Action action = null!; - var ex = Assert.Throws(Test); - - Assert.Equal("action", ex.ParamName); - - void Test() - => - source.ForEach(action); - } - - [Fact] - public void ForEachWithIndex_SourceIsDefault_ExpectActionCalledNever() - { - var source = default(FlatArray); - source.ForEach(Invoke); - - static void Invoke(int index, RecordStruct item) - => - Assert.Fail($"The action for an item '{item}' by the index '{index}' must not be invoked"); - } - - [Fact] - public void ForEachWithIndex_SourceIsNotDefault_ExpectActionCalledForEachItem() - { - var sourceItems = new[] - { - "First", "Second", EmptyString, "Fourth", EmptyString - }; - - var source = sourceItems.InitializeFlatArray(); - - var expectedSequence = new KeyValuePair[] - { - new(0, "First"), - new(1, "Second"), - new(2, EmptyString), - new(3, "Fourth"), - new(4, EmptyString) - }; - - var expectedQueue = new Queue>(expectedSequence); - source.ForEach(Invoke); - - Assert.Empty(expectedQueue); - - void Invoke(int index, string item) - { - var expected = expectedQueue.Dequeue(); - - Assert.StrictEqual(expected.Key, index); - Assert.Equal(expected.Value, item); - } - } - - [Fact] - public void ForEachWithIndex_InnerLengthIsLessThanItemsLength_ExpectActionCalledLengthTimes() - { - var sourceItems = new[] - { - MinusFifteen, One, int.MinValue, PlusFifteen, MinusOne, Zero, int.MaxValue - }; - - var source = sourceItems.InitializeFlatArray(4); - - var expectedQueue = new Queue>(); - - expectedQueue.Enqueue(new(0, MinusFifteen)); - expectedQueue.Enqueue(new(1, One)); - expectedQueue.Enqueue(new(2, int.MinValue)); - expectedQueue.Enqueue(new(3, PlusFifteen)); - - source.ForEach(Invoke); - - Assert.Empty(expectedQueue); - - void Invoke(int index, int item) - { - var expected = expectedQueue.Dequeue(); - - Assert.StrictEqual(expected.Key, index); - Assert.Equal(expected.Value, item); - } - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.GetEnumerator.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.GetEnumerator.cs deleted file mode 100644 index 92e689e..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.GetEnumerator.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void GetEnumerator_SourceIsDefault_ExpectEnumeratorWithDefaultState() - { - var source = default(FlatArray); - var actual = source.GetEnumerator(); - - actual.VerifyInnerState(Array.Empty(), -1); - } - - [Theory] - [InlineData(1, PlusFifteen)] - [InlineData(3, null, MinusFifteen, One, PlusFifteen, MinusOne)] - public void GetEnumerator_SourceIsNotDefault_ExpectEnumeratorWithCorrectState( - int length, params int?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatArray(length); - var actual = source.GetEnumerator(); - - var expectedItems = coppied.Take(length).ToArray(); - actual.VerifyInnerState(expectedItems, -1); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Indexer.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Indexer.cs deleted file mode 100644 index 2fe3b30..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Indexer.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Theory] - [InlineData(MinusFifteen)] - [InlineData(Zero)] - [InlineData(PlusFifteen)] - public void Indexer_SourceIsDefault_ExpectArgumentOutOfRangeException(int index) - { - var source = default(FlatArray); - var ex = Assert.Throws(Test); - - Assert.Equal("index", ex.ParamName); - - void Test() - => - _ = source[index]; - } - - [Theory] - [InlineData(0, 1, EmptyString)] - [InlineData(1, 2, AnotherString, SomeString, LowerSomeString)] - [InlineData(2, 3, SomeString, AnotherString, null, LowerSomeString)] - [InlineData(3, 4, null, "One", "Two", "Three")] - public void Indexer_IndexIsInRange_ExpectItemIsFromSourceItemsByIndex( - int index, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArray(sourceLength); - - var actual = source[index]; - var expected = sourceItems[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, 1, SomeString)] - [InlineData(1, 1, EmptyString, AnotherString)] - [InlineData(5, 2, EmptyString, SomeString)] - [InlineData(-1, 3, LowerSomeString, null, SomeString)] - public void Indexer_IndexIsOutOfRange_ExpectArgumentOutOfRangeException( - int index, int sourceLength, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArray(sourceLength); - var ex = Assert.Throws(Test); - - Assert.Equal("index", ex.ParamName); - - void Test() - => - _ = source[index]; - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.IsEmpty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.IsEmpty.cs deleted file mode 100644 index dfc3849..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.IsEmpty.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void IsEmpty_SourceIsDefault_ExpectTrue() - { - var source = default(FlatArray); - var actual = source.IsEmpty; - - Assert.True(actual); - } - - [Theory] - [InlineData(EmptyString)] - [InlineData(null, SomeString, LowerSomeString, EmptyString, AnotherString)] - public void IsEmpty_SourceIsNotDefault_ExpectFalse( - params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArray(); - var actual = source.IsEmpty; - - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.IsNotEmpty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.IsNotEmpty.cs deleted file mode 100644 index 88f515f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.IsNotEmpty.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void IsNotEmpty_SourceIsDefault_ExpectFalse() - { - var source = default(FlatArray); - var actual = source.IsNotEmpty; - - Assert.False(actual); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(null, EmptyString, UpperSomeString, SomeString, WhiteSpaceString)] - public void IsNotEmpty_SourceIsNotDefault_ExpectFalse( - params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArray(); - var actual = source.IsNotEmpty; - - Assert.True(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Length.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Length.cs deleted file mode 100644 index c4ad3a2..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.Length.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void GetLength_SourceIsDefault_ExpectDefault() - { - var source = default(FlatArray); - - var actual = source.Length; - const int expected = default; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(1, Zero)] - [InlineData(3, PlusFifteen, null, MinusOne)] - [InlineData(2, PlusFifteen, null, MinusOne)] - public void GetLength_SourceIsNotDefault_ExpectInnerLength( - int innerLength, params int?[] innerItems) - { - var source = innerItems.InitializeFlatArray(innerLength); - - var actual = source.Length; - var expected = innerLength; - - Assert.Equal(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.ToString.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.ToString.cs deleted file mode 100644 index a531246..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Array/Array.ToString.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void ToString_SourceIsDefault_ExpectStringContainsZeroAndTypeName() - { - var source = default(FlatArray); - var actual = source.ToString(); - - Assert.Contains("0", actual, StringComparison.InvariantCulture); - Assert.Contains("StructType", actual, StringComparison.InvariantCulture); - } - - [Fact] - public void ToString_InnerLengthIsLessThanInnerItemsLength_ExpectStringContainsLengthAndTypeName() - { - var innerItems = new[] - { - MinusFifteen, PlusFifteen, Zero, int.MaxValue, One - }; - - const int innerLength = 4; - - var source = innerItems.InitializeFlatArray(innerLength); - var actual = source.ToString(); - - Assert.Contains(innerLength.ToString(), actual, StringComparison.InvariantCulture); - Assert.Contains("Int32", actual, StringComparison.InvariantCulture); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Enumerator/Test.Current.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Enumerator/Test.Current.cs deleted file mode 100644 index 810e0ce..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Enumerator/Test.Current.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void Enumerator_Current_SourceIsDefault_ExpectIndexOutOfRangeException() - { - var source = default(FlatArray.Enumerator); - - try - { - _ = source.Current; - } - catch (IndexOutOfRangeException) - { - return; - } - - Assert.Fail("An expected IndexOutOfRangeException was not thrown"); - } - - [Theory] - [InlineData(0, false)] - [InlineData(1, true, null, false)] - [InlineData(4, false, true, true, null, false)] - public void Enumerator_Current_IndexIsInRange_ExpectItemByIndex( - int index, params bool?[] sourceItems) - { - var coppiedItems = sourceItems.GetCopy(); - var source = sourceItems.InitializeFlatArrayEnumerator(index); - - var actual = source.Current; - var expected = coppiedItems[index]; - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0)] - [InlineData(1, SomeString)] - [InlineData(5, AnotherString, EmptyString, null)] - [InlineData(-1, TabString, SomeString)] - public void Enumerator_Current_IndexIsNotInRange_ExpectIndexOutOfRangeException( - int index, params string?[] sourceItems) - { - var source = sourceItems.InitializeFlatArrayEnumerator(index); - - try - { - _ = source.Current; - } - catch (IndexOutOfRangeException) - { - return; - } - - Assert.Fail("An expected IndexOutOfRangeException was not thrown"); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Enumerator/Test.MoveNext.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Enumerator/Test.MoveNext.cs deleted file mode 100644 index cd853f7..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Enumerator/Test.MoveNext.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void Enumerator_MoveNext_SourceIsDefault_ExpectFalseAndDefaultState() - { - var source = default(FlatArray.Enumerator); - var actual = source.MoveNext(); - - Assert.False(actual); - source.VerifyInnerState(Array.Empty(), 0); - } - - [Theory] - [InlineData(-1, MinusFifteen)] - [InlineData(0, null, PlusFifteen, Zero)] - [InlineData(2, MinusOne, PlusFifteen, MinusFifteen, Zero)] - public void Enumerator_MoveNext_IndexIsLessThanLengthMinusOne_ExpectTrueAndNextIndex( - int index, params int?[] items) - { - var coppiedItems = items.GetCopy(); - - var source = items.InitializeFlatArrayEnumerator(index); - var actual = source.MoveNext(); - - Assert.True(actual); - source.VerifyInnerState(coppiedItems, index + 1); - } - - [Theory] - [InlineData(0)] - [InlineData(1, SomeString)] - [InlineData(3, AnotherString, EmptyString)] - public void Enumerator_MoveNext_IndexIsEqualToLengthOrGreate_ExpectFalseAndIndexHasNotChanged( - int index, params string?[] items) - { - var coppied = items.GetCopy(); - - var source = items.InitializeFlatArrayEnumerator(index); - var actual = source.MoveNext(); - - Assert.False(actual); - source.VerifyInnerState(coppied, index); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equality.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equality.cs deleted file mode 100644 index 150917a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equality.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void Equality_LeftIsDefaultAndRightIsDefault_ExpectTrue() - { - var left = default(FlatArray); - var right = default(FlatArray); - - var actual = left == right; - Assert.True(actual); - } - - [Fact] - public void Equality_LeftIsDefaultAndRightIsNotDefault_ExpectFalse() - { - var left = default(FlatArray); - - var right = new RecordStruct[] - { - default - } - .InitializeFlatArray(); - - var actual = left == right; - Assert.False(actual); - } - - [Fact] - public void Equality_LeftIsNotDefaultAndRightIsDefault_ExpectFalse() - { - var left = new RecordType?[] - { - null - } - .InitializeFlatArray(); - - var right = default(FlatArray); - - var actual = left == right; - Assert.False(actual); - } - - [Fact] - public void Equality_LeftLengthIsNotEqualToRightLength_ExpectFalse() - { - var items = new[] { MinusOne, One }; - - var left = items.InitializeFlatArray(2); - var right = items.InitializeFlatArray(1); - - var actual = left == right; - Assert.False(actual); - } - - [Fact] - public void Equality_LeftItemsAreEqualToRightItems_ExpectTrue() - { - var left = new[] - { - null, - SomeString, - EmptyString, - AnotherString - } - .InitializeFlatArray(3); - - var right = new[] - { - null, - SomeString, - EmptyString - } - .InitializeFlatArray(3); - - var actual = left == right; - Assert.True(actual); - } - - [Fact] - public void Equality_LeftItemsAreNotEqualToRightItems_ExpectFalse() - { - var left = new[] - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord - } - .InitializeFlatArray(); - - var right = new[] - { - PlusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord - } - .InitializeFlatArray(); - - var actual = left == right; - Assert.False(actual); - } - - [Fact] - public void Equality_LeftItemsOrderAreNotSameAsRightItemsOrder_ExpectFalse() - { - var left = new[] { SomeTextRecordStruct, default }.InitializeFlatArray(); - var right = new[] { default, SomeTextRecordStruct }.InitializeFlatArray(); - - var actual = left == right; - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Object.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Object.cs deleted file mode 100644 index 08dce41..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Object.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void EqualsWithObject_SourceIsDefaultAndObjectIsNull_ExpectFalse() - { - var source = default(FlatArray); - object? other = null; - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsDefaultAndObjectIsNotFlatArray_ExpectFalse() - { - var source = default(FlatArray); - object? other = default(RecordStruct); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsDefaultAndObjectIsDefaultAnotherType_ExpectFalse() - { - var source = default(FlatArray); - object other = default(FlatArray); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsDefaultAndObjectIsDefaultFlatArray_ExpectTrue() - { - var source = default(FlatArray); - object other = default(FlatArray); - - var actual = source.Equals(other); - Assert.True(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsDefaultAndObjectIsNotDefaultFlatArray_ExpectFalse() - { - var source = default(FlatArray); - - object other = new[] - { - default(int) - } - .InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsNotDefaultAndObjectIsNull_ExpectFalse() - { - var source = new RefType?[] - { - null - } - .InitializeFlatArray(); - - object? other = null; - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsNotDefaultAndObjectIsNotFlatArray_ExpectFalse() - { - var source = new int[] { PlusFifteen }.InitializeFlatArray(); - object? other = new int[] { PlusFifteen }; - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceIsNotDefaultAndObjectIsDefault_ExpectFalse() - { - var source = new string?[] - { - SomeString, AnotherString - } - .InitializeFlatArray(); - - object other = default(FlatArray); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceLengthIsNotEqualToObjectLength_ExpectFalse() - { - var items = new[] { PlusFifteenIdRefType, MinusFifteenIdRefType, null }; - - var source = items.InitializeFlatArray(3); - object other = items.InitializeFlatArray(2); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceItemsAreEqualToObjectAnotherTypeItems_ExpectFalse() - { - var source = new int[] { 25, 31 }.InitializeFlatArray(); - object other = new long[] { 25, 31 }.InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceItemsAreEqualToObjectItems_ExpectTrue() - { - var source = new[] - { - SomeString, - null, - EmptyString, - AnotherString, - WhiteSpaceString - } - .InitializeFlatArray(4); - - object other = new[] - { - SomeString, - null, - EmptyString, - AnotherString, - TabString - } - .InitializeFlatArray(4); - - var actual = source.Equals(other); - Assert.True(actual); - } - - [Fact] - public void EqualsWithObject_SourceItemsAreNotEqualToObjectItems_ExpectFalse() - { - var source = new int?[] - { - PlusFifteen, - null, - MinusOne - } - .InitializeFlatArray(); - - object other = new int?[] - { - PlusFifteen, - One, - null - } - .InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithObject_SourceItemsOrderAreNotSameAsObjectItemsOrder_ExpectFalse() - { - var source = new[] { EmptyString, TabString }.InitializeFlatArray(); - object other = new[] { TabString, EmptyString }.InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Other.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Other.cs deleted file mode 100644 index 8368aae..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Other.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void EqualsWithOther_SourceIsDefaultAndOtherIsDefault_ExpectTrue() - { - var source = default(FlatArray); - var other = default(FlatArray); - - var actual = source.Equals(other); - Assert.True(actual); - } - - [Fact] - public void EqualsWithOther_SourceIsDefaultAndOtherIsNotDefault_ExpectFalse() - { - var source = default(FlatArray); - - var other = new[] - { - default(StructType) - } - .InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithOther_SourceIsNotDefaultAndOtherIsDefault_ExpectFalse() - { - var source = new object?[] - { - null - } - .InitializeFlatArray(); - - var other = default(FlatArray); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithOther_SourceLengthIsNotEqualToOtherLength_ExpectFalse() - { - var items = new[] { EmptyString, SomeString }; - - var source = items.InitializeFlatArray(2); - var other = items.InitializeFlatArray(1); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithOther_SourceItemsAreEqualToOtherItems_ExpectTrue() - { - var source = new RecordType?[] - { - new() { Id = MinusOne, Name = SomeString }, - new() { Id = int.MaxValue, Name = null }, - null, - MinusFifteenIdSomeStringNameRecord, - ZeroIdNullNameRecord - } - .InitializeFlatArray(4); - - var other = new RecordType?[] - { - new() { Id = MinusOne, Name = SomeString }, - new() { Id = int.MaxValue, Name = null }, - null, - MinusFifteenIdSomeStringNameRecord - } - .InitializeFlatArray(4); - - var actual = source.Equals(other); - Assert.True(actual); - } - - [Fact] - public void EqualsWithOther_SourceItemsAreNotEqualToOtherItems_ExpectFalse() - { - var source = new RefType?[] - { - PlusFifteenIdRefType, - new() { Id = int.MaxValue }, - null - } - .InitializeFlatArray(); - - var other = new RefType?[] - { - PlusFifteenIdRefType, - new() { Id = int.MaxValue }, - null - } - .InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } - - [Fact] - public void EqualsWithOther_SourceItemsOrderAreNotSameAsOtherItemsOrder_ExpectFalse() - { - var source = new[] { 1, 2, 3 }.InitializeFlatArray(); - var other = new[] { 1, 3, 2 }.InitializeFlatArray(); - - var actual = source.Equals(other); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Static.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Static.cs deleted file mode 100644 index d59b9bc..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Equals.Static.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void EqualsStatic_LeftIsDefaultAndRightIsDefault_ExpectTrue() - { - var left = default(FlatArray); - var right = default(FlatArray); - - var actual = FlatArray.Equals(left, right); - Assert.True(actual); - } - - [Fact] - public void EqualsStatic_LeftIsDefaultAndRightIsNotDefault_ExpectFalse() - { - var left = default(FlatArray); - var right = new RefType?[] { null }.InitializeFlatArray(); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void EqualsStatic_LeftIsNotDefaultAndRightIsDefault_ExpectFalse() - { - var left = new int[] { default }.InitializeFlatArray(); - var right = default(FlatArray); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void EqualsStatic_LeftLengthIsNotEqualToRightLength_ExpectFalse() - { - var items = new[] { null, MinusFifteenIdRefType, ZeroIdRefType }; - - var left = items.InitializeFlatArray(2); - var right = items.InitializeFlatArray(3); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void EqualsStatic_LeftItemsAreEqualToRightItems_ExpectTrue() - { - var left = new[] { MinusFifteen, MinusOne, Zero }.InitializeFlatArray(3); - var right = new[] { MinusFifteen, MinusOne, Zero, int.MaxValue }.InitializeFlatArray(3); - - var actual = FlatArray.Equals(left, right); - Assert.True(actual); - } - - [Fact] - public void EqualsStatic_LeftItemsAreNotEqualToRightItems_ExpectFalse() - { - var left = new StructType[] { default, SomeTextStructType }.InitializeFlatArray(); - var right = new StructType[] { default, LowerSomeTextStructType }.InitializeFlatArray(); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void EqualsStatic_LeftItemsOrderAreNotSameAsRightItemsOrder_ExpectFalse() - { - var left = new[] { null, MinusFifteenIdRefType }.InitializeFlatArray(); - var right = new[] { MinusFifteenIdRefType, null }.InitializeFlatArray(); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.GetHashCode.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.GetHashCode.cs deleted file mode 100644 index c412679..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.GetHashCode.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void GetHashCode_FirstIsDefaultAndSecondIsDefaultAnotherType_ExpectDifferentHashCodes() - { - var first = default(FlatArray); - var second = default(FlatArray); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } - - [Fact] - public void GetHashCode_SourceIsDefaultAndSecondIsDefault_ExpectEqualHashCodes() - { - var first = default(FlatArray); - var second = default(FlatArray); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.True(actual); - } - - [Fact] - public void GetHashCode_SourceIsDefaultAndSecondIsNotDefault_ExpectDifferentHashCodes() - { - var first = default(FlatArray); - var second = new string?[] { null }.InitializeFlatArray(); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } - - [Fact] - public void GetHashCode_SourceIsNotDefaultAndSecondIsDefault_ExpectDifferentHashCodes() - { - var first = new[] { false, true }.InitializeFlatArray(); - var second = default(FlatArray); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } - - [Fact] - public void GetHashCode_SourceLengthIsNotEqualToSecondLength_ExpectDifferentHashCodes() - { - var items = new int?[] { Zero, PlusFifteen, One }; - - var first = items.InitializeFlatArray(2); - var second = items.InitializeFlatArray(3); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } - - [Fact] - public void GetHashCode_SourceItemsAreEqualToSecondAnotherTypeItems_ExpectDifferentHashCodes() - { - var first = new StructType?[] { SomeTextStructType, AnotherTextStructType }.InitializeFlatArray(); - var second = new StructType[] { SomeTextStructType, AnotherTextStructType }.InitializeFlatArray(); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } - - [Fact] - public void GetHashCode_SourceItemsAreEqualToSecondItems_ExpectEqualHashCodes() - { - var first = new RecordType?[] - { - new() { Id = One }, - null, - new() { Id = MinusFifteen, Name = "Some name" } - } - .InitializeFlatArray(); - - var second = new RecordType?[] - { - new() { Id = One }, - null, - new() { Id = MinusFifteen, Name = "Some name" } - } - .InitializeFlatArray(); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.True(actual); - } - - [Fact] - public void GetHashCode_SourceItemsAreNotEqualToSecondItems_ExpectDifferentHashCodes() - { - var first = new[] { SomeString, EmptyString, WhiteSpaceString }.InitializeFlatArray(); - var second = new[] { SomeString, EmptyString, TabString }.InitializeFlatArray(); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } - - [Fact] - public void GetHashCode_SourceItemsOrderAreNotSameAsSecondItemsOrder_ExpectDifferentHashCodes() - { - var first = new int?[] { One, null, PlusFifteen }.InitializeFlatArray(); - var second = new int?[] { One, PlusFifteen, null }.InitializeFlatArray(); - - var firstHashCode = first.GetHashCode(); - var secondHashCode = second.GetHashCode(); - - var actual = firstHashCode == secondHashCode; - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Inequality.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Inequality.cs deleted file mode 100644 index b0109cb..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Equality/Equality.Inequality.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void Inequality_LeftIsDefaultAndRightIsDefault_ExpectFalse() - { - var left = default(FlatArray); - var right = default(FlatArray); - - var actual = left != right; - Assert.False(actual); - } - - [Fact] - public void Inequality_LeftIsDefaultAndRightIsNotDefault_ExpectTrue() - { - var left = default(FlatArray); - - var right = new RefType?[] - { - PlusFifteenIdRefType - } - .InitializeFlatArray(); - - var actual = left != right; - Assert.True(actual); - } - - [Fact] - public void Inequality_LeftIsNotDefaultAndRightIsDefault_ExpectTrue() - { - var left = new byte?[] - { - null - } - .InitializeFlatArray(); - - var right = default(FlatArray); - - var actual = left != right; - Assert.True(actual); - } - - [Fact] - public void Inequality_LeftLengthIsNotEqualToRightLength_ExpectTrue() - { - var items = new bool?[] { true, null, false }; - - var left = items.InitializeFlatArray(3); - var right = items.InitializeFlatArray(2); - - var actual = left != right; - Assert.True(actual); - } - - [Fact] - public void Inequality_LeftItemsAreEqualToRightItems_ExpectFalse() - { - var left = new object?[] - { - null, - new { Id = One, Name = SomeString }, - new { Id = PlusFifteen, Name = AnotherString } - } - .InitializeFlatArray(2); - - var right = new object?[] - { - null, - new { Id = One, Name = SomeString }, - new { Id = PlusFifteen, Name = AnotherString }, - new() - } - .InitializeFlatArray(2); - - var actual = left != right; - Assert.False(actual); - } - - [Fact] - public void Inequality_LeftItemsAreNotEqualToRightItems_ExpectTrue() - { - var left = new[] - { - decimal.One, decimal.MaxValue - } - .InitializeFlatArray(); - - var right = new[] - { - decimal.MinusOne, decimal.MaxValue - } - .InitializeFlatArray(); - - var actual = left != right; - Assert.True(actual); - } - - [Fact] - public void Inequality_LeftItemsOrderAreNotSameAsRightItemsOrder_ExpectTrue() - { - var left = new[] { MinusFifteenIdRefType, ZeroIdRefType, PlusFifteenIdRefType }.InitializeFlatArray(); - var right = new[] { PlusFifteenIdRefType, ZeroIdRefType, MinusFifteenIdRefType }.InitializeFlatArray(); - - var actual = left != right; - Assert.True(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Constructor.1_16.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Constructor.1_16.cs deleted file mode 100644 index 1f040ae..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Constructor.1_16.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Theory] - [InlineData(null)] - [InlineData(PlusFifteen)] - public void ConstructFromOneItem_ExpectInnerStateIsSourceItem(int? item) - { - var actual = new FlatArray(item); - - const int expectedLength = 1; - var expectedItems = new[] { item }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromTwoItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray(PlusFifteenIdLowerSomeStringNameRecord, null); - - const int expectedLength = 2; - var expectedItems = new[] { PlusFifteenIdLowerSomeStringNameRecord, null }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromThreeItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray(SomeString, AnotherString, string.Empty); - - const int expectedLength = 3; - var expectedItems = new[] { SomeString, AnotherString, string.Empty }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFourItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray(null, PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType); - - const int expectedLength = 4; - var expectedItems = new[] { null, PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFiveItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray(51, 2801, -71, int.MaxValue, 67); - - const int expectedLength = 5; - var expectedItems = new[] { 51, 2801, -71, int.MaxValue, 67 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromSixItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray("1:One", "2:Two", "3:Three", "4:Four", "5:Five", null); - - const int expectedLength = 6; - var expectedItems = new[] { "1:One", "2:Two", "3:Three", "4:Four", "5:Five", null }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromSevenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - null, 1478, -791, double.PositiveInfinity, 78.891, 9, double.Epsilon); - - const int expectedLength = 7; - - var expectedItems = new double?[] - { - null, 1478, -791, double.PositiveInfinity, 78.891, 9, double.Epsilon - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromEightItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - 189165, 41, 6, 0, 891, 2546, 64, 147); - - const int expectedLength = 8; - - var expectedItems = new uint[] - { - 189165, 41, 6, 0, 891, 2546, 64, 147 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromNineItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - SomeString, LowerAnotherString, null, EmptyString, AnotherString, - UpperSomeString, WhiteSpaceString, UpperAnotherString, TabString); - - const int expectedLength = 9; - - var expectedItems = new[] - { - SomeString, LowerAnotherString, null, EmptyString, AnotherString, - UpperSomeString, WhiteSpaceString, UpperAnotherString, TabString - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromTenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - 127, 95, 221, 54, 7, 86, 74, 1, 82, 17); - - const int expectedLength = 10; - - var expectedItems = new byte[] - { - 127, 95, 221, 54, 7, 86, 74, 1, 82, 17 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromElevenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - "Eleventh", "Tenth", "Ninth", "Eighth", "Seventh", null, - "Fifth", "Fourth", "Third", "Second", "First"); - - const int expectedLength = 11; - - var expectedItems = new[] - { - "Eleventh", "Tenth", "Ninth", "Eighth", "Seventh", null, - "Fifth", "Fourth", "Third", "Second", "First" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromTwelveItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - 68, 982, 75, 30121, 5007, int.MinValue, - 871, Zero, 551, -3092, 27, -893); - - const int expectedLength = 12; - - var expectedItems = new[] - { - 68, 982, 75, 30121, 5007, int.MinValue, - 871, Zero, 551, -3092, 27, -893 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromThirteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - "First", "Second", "Third", "Fourth", "Fifth", "Sixth", string.Empty, - "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth", "Thirteenth"); - - const int expectedLength = 13; - - var expectedItems = new[] - { - "First", "Second", "Third", "Fourth", "Fifth", "Sixth", string.Empty, - "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth", "Thirteenth" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFourteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - -205, long.MaxValue, 78, 9717253, 27, -125, 51, - long.MinValue, 11, 27, 95123, Zero, 82, 61); - - const int expectedLength = 14; - - var expectedItems = new[] - { - -205, long.MaxValue, 78, 9717253, 27, -125, 51, - long.MinValue, 11, 27, 95123, Zero, 82, 61 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromFifteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - 71, 22, 789, int.MinValue, 157, PlusFifteen, 102937, -91, - 78612, -21, -188, Zero, int.MaxValue, PlusFifteen, 51); - - const int expectedLength = 15; - - var expectedItems = new[] - { - 71, 22, 789, int.MinValue, 157, PlusFifteen, 102937, -91, - 78612, -21, -188, Zero, int.MaxValue, PlusFifteen, 51 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ConstructFromSixteenItems_ExpectInnerStateIsSourceItems() - { - var actual = new FlatArray( - "One", "Two", "Three", "Four", "Five", null, "Seven", "Eight", - "Nine", "Ten", "Eleven", "Twelve", string.Empty, "Fourteen", "Fifteen", "Sixteen"); - - const int expectedLength = 16; - - var expectedItems = new[] - { - "One", "Two", "Three", "Four", "Five", null, "Seven", "Eight", - "Nine", "Ten", "Eleven", "Twelve", string.Empty, "Fourteen", "Fifteen", "Sixteen" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Constructor.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Constructor.cs deleted file mode 100644 index eac84f5..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Constructor.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void ConstructFromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - int[]? source = null; - var actual = new FlatArray(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ConstructFromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = new FlatArray(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(null, LowerAnotherString, EmptyString, WhiteSpaceString, UpperSomeString)] - [InlineData("01", "02", "03", null, "05", "06", "07", "08", "09", "10", EmptyString, "12", "13", "14", "15", "16", "17")] - public void ConstructFromArray_SourceIsNotEmpty_ExpectInnerStateIsSource( - params string?[] source) - { - var coppied = source.GetCopy(); - var actual = new FlatArray(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void ConstructFromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { MinusFifteen, Zero, int.MaxValue }; - var actual = new FlatArray(sourceArray); - - sourceArray[0] = PlusFifteen; - var expectedItems = new[] { MinusFifteen, Zero, int.MaxValue }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.Empty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.Empty.cs deleted file mode 100644 index 32542c0..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.Empty.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void Empty_ExpectInnerStateIsDefault() - { - var actual = FlatArray.Empty; - actual.VerifyInnerState(default, default); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.1_16.cs deleted file mode 100644 index 00c9019..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.1_16.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Theory] - [InlineData(null)] - [InlineData(SomeString)] - public void FromOneItem_ExpectInnerStateIsSourceItem(string? item) - { - var actual = FlatArray.From(item); - - const int expectedLength = 1; - var expectedItems = new[] { item }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwoItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(SomeTextStructType, LowerSomeTextStructType); - - const int expectedLength = 2; - var expectedItems = new[] { SomeTextStructType, LowerSomeTextStructType }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThreeItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(null, MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord); - - const int expectedLength = 3; - var expectedItems = new[] { null, MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(string.Empty, SomeString, AnotherString, EmptyString); - - const int expectedLength = 4; - var expectedItems = new[] { string.Empty, SomeString, AnotherString, EmptyString }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFiveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - new(2021, 11, 05), new(2022, 07, 15), new(2019, 02, 14), new(1997, 12, 01), new(2015, 03, 01)); - - const int expectedLength = 5; - - var expectedItems = new DateOnly[] - { - new(2021, 11, 05), new(2022, 07, 15), new(2019, 02, 14), new(1997, 12, 01), new(2015, 03, 01) - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - -89, -35, 57, 0, 789, 56341); - - const int expectedLength = 6; - - var expectedItems = new long[] - { - -89, -35, 57, 0, 789, 56341 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - null, SomeString, MinusFifteenIdRefType, MinusFifteen, false, LowerSomeTextStructType, byte.MaxValue); - - const int expectedLength = 7; - - var expectedItems = new object?[] - { - null, SomeString, MinusFifteenIdRefType, MinusFifteen, false, LowerSomeTextStructType, byte.MaxValue - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromEightItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - -751.81m, decimal.MinusOne, null, 178, -7531, -69, 275, 935); - - const int expectedLength = 8; - - var expectedItems = new decimal?[] - { - -751.81m, decimal.MinusOne, null, 178, -7531, -69, 275, 935 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromNineItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - 264, -891, long.MaxValue, 0, 24681, -90, -1, 755, 681); - - const int expectedLength = 9; - - var expectedItems = new long?[] - { - 264, -891, long.MaxValue, 0, 24681, -90, -1, 755, 681 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, 17892, null, -32, -955); - - const int expectedLength = 10; - - var expectedItems = new int?[] - { - MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, 17892, null, -32, -955 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromElevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - decimal.MinusOne, 8691.719m, 1361, -789018, 75, 682, - 827, 954, decimal.MaxValue, 13289, 88); - - const int expectedLength = 11; - - var expectedItems = new[] - { - decimal.MinusOne, 8691.719m, 1361, -789018, 75, 682, - 827, 954, decimal.MaxValue, 13289, 88 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwelveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - -75, 2155, 790, 825, 351, 541, - 975601, long.MaxValue, 7891, null, 571, 622); - - const int expectedLength = 12; - - var expectedItems = new long?[] - { - -75, 2155, 790, 825, 351, 541, - 975601, long.MaxValue, 7891, null, 571, 622 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThirteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, - -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75); - - const int expectedLength = 13; - - var expectedItems = new[] - { - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, - -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - 0, 2, 6, 3, 91, byte.MaxValue, 71, - 5, 71, 52, 122, 211, 86, 23); - - const int expectedLength = 14; - - var expectedItems = new byte[] - { - 0, 2, 6, 3, 91, byte.MaxValue, 71, - 5, 71, 52, 122, 211, 86, 23 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFifteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", string.Empty, "Nine", - "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One"); - - const int expectedLength = 15; - - var expectedItems = new[] - { - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", string.Empty, "Nine", - "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - decimal.MinusOne, 178.81m, 24, -75195.71m, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m); - - const int expectedLength = 16; - - var expectedItems = new[] - { - decimal.MinusOne, 178.81m, 24, -75195.71m, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.Span.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.Span.cs deleted file mode 100644 index d8b0809..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.Span.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void FromReadOnlySpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = default(ReadOnlySpan); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData("First", "Second", "Third")] - public void FromReadOnlySpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params string?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = new ReadOnlySpan(sourceItems); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromSpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = default(Span); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromSpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - Span source = stackalloc int[] { 5, 11, -17, 27, -81 }; - var actual = FlatArray.From(source); - - const int expectedLength = 5; - var expectedItems = new[] { 5, 11, -17, 27, -81 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSpan_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceItems = new[] - { - PlusFifteenIdRefType, ZeroIdRefType - }; - - var source = sourceItems.AsSpan(); - var actual = FlatArray.From(source); - - source[0] = MinusFifteenIdRefType; - - var expectedItems = new[] - { - PlusFifteenIdRefType, ZeroIdRefType - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.cs deleted file mode 100644 index 6fbd15f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Explicit.From.cs +++ /dev/null @@ -1,367 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void FromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - object?[]? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(Zero)] - [InlineData(PlusFifteen, null, MinusFifteen, PlusFifteen)] - [InlineData(12, 15, 1, 91, 7, -95, null, 0, 5, 6, 7, 901, 98, -266, 78, 62, 21, 35, 75, 212, 51)] - public void FromArray_SourceIsNotEmpty_ExpectInnerStateIsSourceArray( - params int?[] source) - { - var coppied = source.GetCopy(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { "One", "Two", "Three" }; - var actual = FlatArray.From(sourceArray); - - sourceArray[1] = "2"; - var expectedItems = new[] { "One", "Two", "Three" }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(FlatArray); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString, AnotherString)] - [InlineData(LowerSomeString, null, SomeString, EmptyString, WhiteSpaceString)] - public void FromFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray( - params string?[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.InitializeFlatArray(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNull_ExpectInnerStateIsDefault() - { - var source = default(FlatArray?); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - FlatArray? source = default(FlatArray); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray() - { - FlatArray? source = new bool?[] { false, null, true }.InitializeFlatArray(); - - var actual = FlatArray.From(source); - var expectedItems = new bool?[] { false, null, true }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromList_SourceIsNull_ExpectInnerStateIsDefault() - { - List? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new List(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var source = new List - { - SomeTextRecordStruct, null, AnotherTextRecordStruct - }; - - var actual = FlatArray.From(source); - - const int expectedLength = 3; - var expectedItems = new RecordStruct?[] - { - SomeTextRecordStruct, null, AnotherTextRecordStruct - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromList_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - var actual = FlatArray.From(sourceList); - - sourceList[0] = PlusFifteenIdLowerSomeStringNameRecord; - sourceList.Add(MinusFifteenIdNullNameRecord); - - const int expectedLength = 3; - var expectedItems = new[] - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(ImmutableArray); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(LowerSomeString, null, AnotherString)] - public void FromImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems( - params string?[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.ToImmutableArray(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsNull_ExpectInnerStateIsDefault() - { - ImmutableArray? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - ImmutableArray? source = new ImmutableArray();; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(PlusFifteen)] - [InlineData(null, MinusFifteen, Zero)] - public void FromNullableImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems( - params int?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = sourceItems.ToImmutableArray(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromEnumerable_SourceIsNull_ExpectInnerStateIsDefault() - { - IEnumerable? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromEnumerable_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Enumerable.Empty(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(AnotherString)] - [InlineData("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12")] - public void FromEnumerable_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params string[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = GetSource(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - - IEnumerable GetSource() - { - foreach (var item in sourceItems) - { - yield return item; - } - } - } - - [Fact] - public void FromCollection_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new StubCollection(new()); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromCollection_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new List - { - PlusFifteenIdRefType, ZeroIdRefType, null - }; - - var source = new StubCollection(sourceItems); - var actual = FlatArray.From(source); - - var expectedItems = new[] - { - PlusFifteenIdRefType, ZeroIdRefType, null - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromCollection_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - SomeTextStructType, default - }; - - var source = new StubCollection(sourceList); - var actual = FlatArray.From(source); - - source.Remove(SomeTextStructType); - - var expectedItems = new[] - { - SomeTextStructType, default - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromReadOnlyList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new StubReadOnlyList(new()); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromReadOnlyList_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new List - { - SomeTextRecordStruct, AnotherTextRecordStruct, UpperAnotherTextRecordStruct - }; - - var source = new StubCollection(sourceItems); - var actual = FlatArray.From(source); - - var expectedItems = new[] - { - SomeTextRecordStruct, AnotherTextRecordStruct, UpperAnotherTextRecordStruct - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromReadOnlyCollection_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var sourceItems = Array.Empty(); - var source = new StubReadOnlyCollection(sourceItems); - - var actual = FlatArray.From(source); - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromReadOnlyCollection_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] - { - null, PlusFifteenIdRefType, ZeroIdRefType - }; - - var source = new StubReadOnlyCollection(sourceItems); - var actual = FlatArray.From(source); - - var expectedItems = new[] - { - null, PlusFifteenIdRefType, ZeroIdRefType - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Implicit.From.Span.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Implicit.From.Span.cs deleted file mode 100644 index bed1818..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Implicit.From.Span.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void ImplicitFromReadOnlySpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - FlatArray actual = default(ReadOnlySpan); - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(PlusFifteen)] - [InlineData(Zero, MinusFifteen, One, int.MaxValue)] - public void ImplicitFromReadOnlySpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params int[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - FlatArray actual = new ReadOnlySpan(sourceItems); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void ImplicitFromSpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - FlatArray actual = default(Span); - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ImplicitFromSpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] { MinusFifteenIdRefType, ZeroIdRefType, null }; - FlatArray actual = new Span(sourceItems); - - actual.VerifyInnerState(sourceItems, sourceItems.Length); - } - - [Fact] - public void ImplicitFromSpan_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceItems = new[] { 1, 71, -289, 55, 91 }; - var source = sourceItems.AsSpan(); - - FlatArray actual = source; - source[0] += 5; - - var expectedItems = new[] { 1, 71, -289, 55, 91 }; - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Implicit.From.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Implicit.From.cs deleted file mode 100644 index 91d38dc..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/Factory/Factory.Implicit.From.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void ImplicitFromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - StructType[]? source = null; - FlatArray actual = source; - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ImplicitFromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - FlatArray actual = Array.Empty(); - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(null, SomeString, AnotherString, LowerSomeString)] - public void ImplicitFromArray_SourceIsNotEmpty_ExpectInnerStateIsSourceArray( - params string?[] source) - { - var coppied = source.GetCopy(); - FlatArray actual = source; - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void ImplicitFromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { MinusOne, PlusFifteen, MinusFifteen }; - FlatArray actual = sourceArray; - - sourceArray[0] += 1; - var expectedItems = new[] { MinusOne, PlusFifteen, MinusFifteen }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ImplicitFromList_SourceIsNull_ExpectInnerStateIsDefault() - { - List? source = null; - FlatArray actual = source; - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ImplicitFromList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - FlatArray actual = new List(); - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ImplicitFromList_SourceIsNotEmpty_ExpectInnerStateIsSourceArray() - { - var source = new List - { - SomeString, EmptyString - }; - - FlatArray actual = source; - - var expectedItems = new[] - { - SomeString, EmptyString - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ImplicitFromList_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - 0, 75, byte.MaxValue, 121, 235, null - }; - - FlatArray actual = sourceList; - - sourceList[3] = 21; - sourceList.Add(97); - - var expectedItems = new byte?[] - { - 0, 75, byte.MaxValue, 121, 235, null - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ImplicitFromImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(ImmutableArray); - FlatArray actual = source; - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ImplicitFromImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems() - { - var sourceBuilder = ImmutableArray.CreateBuilder(5); - - sourceBuilder.Add("One"); - sourceBuilder.Add("Two"); - sourceBuilder.Add("Three"); - sourceBuilder.Add("Four"); - sourceBuilder.Add(null); - - FlatArray actual = sourceBuilder.ToImmutable(); - - var expectedItems = new[] - { - "One", "Two", "Three", "Four", null - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/FlatArrayTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/FlatArrayTest.cs deleted file mode 100644 index d67fa3a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/FlatArrayTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.AsMemory.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.AsMemory.cs deleted file mode 100644 index fa343c4..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.AsMemory.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void AsMemory_SourceIsDefault_ExpectDefault() - { - var source = default(FlatArray); - - var actual = source.AsMemory(); - var expected = default(ReadOnlyMemory); - - Assert.StrictEqual(expected, actual); - } - - [Fact] - public void AsMemory_SourceIsNotDefault_ExpectSourceItems() - { - var sourceItems = new[] - { - PlusFifteenIdRefType, ZeroIdRefType, null, MinusFifteenIdRefType - }; - - var source = sourceItems.InitializeFlatArray(); - - var actual = source.AsMemory(); - var expected = sourceItems.AsMemory(); - - Assert.StrictEqual(expected, actual); - } - - [Fact] - public void AsMemory_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - SomeString, null, EmptyString, AnotherString, WhiteSpaceString - }; - - const int innerLength = 3; - var source = sourceItems.InitializeFlatArray(innerLength); - - var actual = source.AsMemory(); - var expected = new Memory(sourceItems, 0, innerLength); - - Assert.StrictEqual(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.AsSpan.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.AsSpan.cs deleted file mode 100644 index 4cff679..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.AsSpan.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void AsSpan_SourceIsDefault_ExpectDefault() - { - var source = default(FlatArray); - - var actual = source.AsSpan(); - var expected = default(ReadOnlySpan); - - Assert.True(expected == actual); - } - - [Fact] - public void AsSpan_SourceIsNotDefault_ExpectSourceItems() - { - var sourceItems = new[] - { - SomeTextRecordStruct, AnotherTextRecordStruct - }; - - var source = sourceItems.InitializeFlatArray(); - - var actual = source.AsSpan(); - var expected = sourceItems.AsSpan(); - - Assert.True(expected == actual); - } - - [Fact] - public void AsSpan_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - MinusFifteen, PlusFifteen, One - }; - - const int innerLength = 2; - var source = sourceItems.InitializeFlatArray(innerLength); - - var actual = source.AsSpan(); - var expected = new ReadOnlySpan(sourceItems, 0, innerLength); - - Assert.True(expected == actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.Explicit.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.Explicit.cs deleted file mode 100644 index d4de272..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.Explicit.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void ToArray_SourceIsDefault_ExpectEmptyArray() - { - var source = default(FlatArray); - - var actual = source.ToArray(); - var expected = Array.Empty(); - - Assert.Equal(expected, actual); - } - - [Fact] - public void ToArray_SourceIsNotDefault_ExpectInnerItems() - { - var sourceItems = new RecordStruct?[] - { - SomeTextRecordStruct, null, default(RecordStruct), AnotherTextRecordStruct - }; - - var source = sourceItems.InitializeFlatArray(); - var actual = source.ToArray(); - - Assert.Equal(sourceItems, actual); - } - - [Fact] - public void ToArray_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - EmptyString, AnotherString, SomeString, LowerSomeString, WhiteSpaceString - }; - - var source = sourceItems.InitializeFlatArray(4); - var actual = source.ToArray(); - - var expected = new[] - { - EmptyString, AnotherString, SomeString, LowerSomeString - }; - - Assert.Equal(expected, actual); - } - - [Fact] - public void ToArray_ThanModifyResult_ExpectInnerStateHasNotChanged() - { - var sourceItems = new RefType[] - { - PlusFifteenIdRefType, MinusFifteenIdRefType - }; - - var source = sourceItems.InitializeFlatArray(); - var result = source.ToArray(); - - result[0] = ZeroIdRefType; - source.VerifyInnerState(sourceItems, 2); - } - - [Fact] - public void ToList_SourceIsDefault_ExpectEmptyList() - { - var source = default(FlatArray); - var actual = source.ToList(); - - Assert.Empty(actual); - } - - [Fact] - public void ToList_SourceIsNotDefault_ExpectInnerItems() - { - var sourceItems = new RecordType[] - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, MinusFifteenIdNullNameRecord - }; - - var source = sourceItems.InitializeFlatArray(); - var actual = source.ToList(); - - Assert.Equal(sourceItems, actual); - } - - [Fact] - public void ToList_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - PlusFifteenIdRefType, null, MinusFifteenIdRefType - }; - - var source = sourceItems.InitializeFlatArray(2); - var actual = source.ToList(); - - var expected = new List - { - PlusFifteenIdRefType, null - }; - - Assert.Equal(expected, actual); - } - - [Fact] - public void ToList_ThanModifyResult_ExpectInnerStateHasNotChanged() - { - var sourceItems = new string[] - { - SomeString, LowerAnotherString, EmptyString - }; - - var source = sourceItems.InitializeFlatArray(); - var result = source.ToList(); - - result[1] = MixedWhiteSpacesString; - result.Remove(SomeString); - - source.VerifyInnerState(sourceItems, 3); - } - - [Fact] - public void ToImmutableArray_SourceIsDefault_ExpectEmptyImmutableArray() - { - var source = default(FlatArray); - - var actual = source.ToImmutableArray(); - var expected = ImmutableArray.Empty; - - Assert.StrictEqual(expected, actual); - } - - [Fact] - public void ToImmutableArray_SourceIsNotDefault_ExpectInnerItems() - { - var sourceItems = new string[] - { - "One", "Two", "Three", "Four", "Five" - }; - - var source = sourceItems.InitializeFlatArray(); - var actual = source.ToImmutableArray(); - - Assert.Equal(sourceItems, actual); - } - - [Fact] - public void ToImmutableArray_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - SomeTextRecordStruct, AnotherTextRecordStruct - }; - - var source = sourceItems.InitializeFlatArray(1); - - var actual = source.ToImmutableArray(); - var expected = new[] { SomeTextRecordStruct }.ToImmutableArray(); - - Assert.Equal>(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.Implicit.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.Implicit.cs deleted file mode 100644 index 818a4dd..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray.T/ToCollecton/ToCollection.Implicit.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayTest -{ - [Fact] - public void ImplicitToArray_SourceIsDefault_ExpectEmptyArray() - { - StructType[] actual = default(FlatArray); - var expected = Array.Empty(); - - Assert.Equal(expected, actual); - } - - [Fact] - public void ImplicitToArray_SourceIsNotDefault_ExpectInnerItems() - { - var sourceItems = new RefType[] - { - ZeroIdRefType, PlusFifteenIdRefType - }; - - RefType[] actual = sourceItems.InitializeFlatArray(); - Assert.Equal(sourceItems, actual); - } - - [Fact] - public void ImplicitToArray_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - decimal.One, decimal.MinusOne - }; - - var source = sourceItems.InitializeFlatArray(1); - decimal[] actual = source; - - var expected = new[] - { - decimal.One - }; - - Assert.Equal(expected, actual); - } - - [Fact] - public void ImplicitToArray_ThanModifyResult_ExpectInnerStateHasNotChanged() - { - var sourceItems = new[] - { - MinusOne, PlusFifteen, Zero - }; - - var source = sourceItems.InitializeFlatArray(); - int[] result = source; - - result[2] += 1; - source.VerifyInnerState(sourceItems, 3); - } - - [Fact] - public void ImplicitToList_SourceIsDefault_ExpectEmptyList() - { - List actual = default(FlatArray); - Assert.Empty(actual); - } - - [Fact] - public void ImplicitToList_SourceIsNotDefault_ExpectInnerItems() - { - var sourceItems = new bool?[] - { - false, null, true - }; - - List actual = sourceItems.InitializeFlatArray(); - Assert.Equal(sourceItems, actual); - } - - [Fact] - public void ImplicitToList_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new RecordStruct?[] - { - default(RecordStruct), SomeTextRecordStruct, AnotherTextRecordStruct, null - }; - - var source = sourceItems.InitializeFlatArray(3); - List actual = source; - - var expected = new List - { - default(RecordStruct), SomeTextRecordStruct, AnotherTextRecordStruct - }; - - Assert.Equal(expected, actual); - } - - [Fact] - public void ImplicitToList_ThanModifyResult_ExpectInnerStateHasNotChanged() - { - var sourceItems = new[] - { - SomeTextStructType, LowerSomeTextStructType - }; - - var source = sourceItems.InitializeFlatArray(); - List result = source; - - result[0] = default; - result.Remove(LowerSomeTextStructType); - - source.VerifyInnerState(sourceItems, 2); - } - - [Fact] - public void ImplicitToImmutableArray_SourceIsDefault_ExpectEmptyImmutableArray() - { - ImmutableArray actual = default(FlatArray); - var expected = ImmutableArray.Empty; - - Assert.StrictEqual(expected, actual); - } - - [Fact] - public void ImplicitToImmutableArray_SourceIsNotDefault_ExpectInnerItems() - { - var sourceItems = new int?[] - { - MinusFifteen, One, PlusFifteen - }; - - ImmutableArray actual = sourceItems.InitializeFlatArray(); - Assert.Equal(sourceItems, actual); - } - - [Fact] - public void ImplicitToImmutableArray_InnerLengthIsLessThanItemsLength_ExpectLengthIsEqualToInnerLength() - { - var sourceItems = new[] - { - EmptyString, null, SomeString, UpperAnotherString, AnotherString - }; - - ImmutableArray actual = sourceItems.InitializeFlatArray(3); - var expected = new[] { EmptyString, null, SomeString }.ToImmutableArray(); - - Assert.Equal>(expected, actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/FlatArrayStaticTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/FlatArrayStaticTest.cs deleted file mode 100644 index b440309..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/FlatArrayStaticTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayStaticTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.Empty.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.Empty.cs deleted file mode 100644 index af08319..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.Empty.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayStaticTest -{ - [Fact] - public void Empty_ExpectInnerStateIsDefault() - { - var actual = FlatArray.Empty(); - actual.VerifyInnerState(default, default); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.Equals.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.Equals.cs deleted file mode 100644 index b4cdbdc..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.Equals.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayStaticTest -{ - [Fact] - public void Equals_LeftIsDefaultAndRightIsDefault_ExpectTrue() - { - var left = default(FlatArray); - var right = default(FlatArray); - - var actual = FlatArray.Equals(left, right); - Assert.True(actual); - } - - [Fact] - public void Equals_LeftIsDefaultAndRightIsNotDefault_ExpectFalse() - { - var left = default(FlatArray); - var right = new StructType[] { default } .InitializeFlatArray(); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void Equals_LeftIsNotDefaultAndRightIsDefault_ExpectFalse() - { - var left = new string?[] { null }.InitializeFlatArray(); - var right = default(FlatArray); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void Equals_LeftLengthIsNotEqualToRightLength_ExpectFalse() - { - var items = new[] { PlusFifteen, MinusOne, int.MaxValue, Zero, One }; - - var left = items.InitializeFlatArray(4); - var right = items.InitializeFlatArray(3); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void Equals_LeftItemsAreEqualToRightItems_ExpectTrue() - { - var left = new[] { null, SomeString, AnotherString }.InitializeFlatArray(3); - var right = new[] { null, SomeString, AnotherString }.InitializeFlatArray(3); - - var actual = FlatArray.Equals(left, right); - Assert.True(actual); - } - - [Fact] - public void Equals_LeftItemsAreNotEqualToRightItems_ExpectFalse() - { - var left = new[] { true, false }.InitializeFlatArray(); - var right = new[] { false, true }.InitializeFlatArray(); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } - - [Fact] - public void Equals_LeftItemsOrderAreNotSameAsRightItemsOrder_ExpectFalse() - { - var left = new[] { SomeTextStructType, default }.InitializeFlatArray(); - var right = new[] { default, SomeTextStructType }.InitializeFlatArray(); - - var actual = FlatArray.Equals(left, right); - Assert.False(actual); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.1_16.cs deleted file mode 100644 index b6f7492..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.1_16.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System.Collections.Generic; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayStaticTest -{ - [Theory] - [InlineData(null)] - [InlineData(MinusFifteen)] - public void FromOneItem_ExpectInnerStateIsSourceItem(int? item) - { - var actual = FlatArray.From(item); - - const int expectedLength = 1; - var expectedItems = new[] { item }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwoItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(MinusFifteenIdRefType, null); - - const int expectedLength = 2; - var expectedItems = new[] { MinusFifteenIdRefType, null }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThreeItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(SomeTextRecordStruct, default, AnotherTextRecordStruct); - - const int expectedLength = 3; - var expectedItems = new[] { SomeTextRecordStruct, default, AnotherTextRecordStruct }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(TabString, null, AnotherString, SomeString); - - const int expectedLength = 4; - var expectedItems = new[] { TabString, null, AnotherString, SomeString }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFiveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(151, 21, byte.MaxValue, 211, 55); - - const int expectedLength = 5; - var expectedItems = new byte[] { 151, 21, byte.MaxValue, 211, 55 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(decimal.MinusOne, 251.7m, null, -252, 97.86m, 751); - - const int expectedLength = 6; - var expectedItems = new decimal?[] { decimal.MinusOne, 251.7m, null, -252, 97.86m, 751 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From("One", "Two", "Three", "Four", "Five", null, "Seven"); - - const int expectedLength = 7; - var expectedItems = new[] { "One", "Two", "Three", "Four", "Five", null, "Seven" }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromEightItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - PlusFifteen, null, SomeString, decimal.MinusOne, byte.MaxValue, false, int.MinValue, AnotherString); - - const int expectedLength = 8; - - var expectedItems = new object?[] - { - PlusFifteen, null, SomeString, decimal.MinusOne, byte.MaxValue, false, int.MinValue, AnotherString - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromNineItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(long.MinValue, -891, -3781, 0, 24681, -90, -1, null, 681); - - const int expectedLength = 9; - var expectedItems = new long?[] { long.MinValue, -891, -3781, 0, 24681, -90, -1, null, 681 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From(MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, default, 27, -32, -955); - - const int expectedLength = 10; - var expectedItems = new[] { MinusFifteen, 861, Zero, int.MaxValue, 168, -90123, default, 27, -32, -955 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromElevenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - decimal.MinusOne, 8691.719m, 1361, null, 75, 682, 827, 954, decimal.MaxValue, 13289, 88); - - const int expectedLength = 11; - - var expectedItems = new decimal?[] - { - decimal.MinusOne, 8691.719m, 1361, null, 75, 682, 827, 954, decimal.MaxValue, 13289, 88 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromTwelveItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - -75, 2155, 790, 825, 351, 541, 975601, long.MaxValue, 7891, null, 571, 622); - - const int expectedLength = 12; - - var expectedItems = new long?[] - { - -75, 2155, 790, 825, 351, 541, 975601, long.MaxValue, 7891, null, 571, 622 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromThirteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75); - - const int expectedLength = 13; - - var expectedItems = new[] - { - 98, -276.54, 681, double.Epsilon, -89.7801, 9950, double.MaxValue, -5.985, double.PositiveInfinity, 98.71, -9701, 72, 75 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFourteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - 0, 2, 6, 3, 91, byte.MaxValue, 71, 5, 71, 52, null, 211, 86, 23); - - const int expectedLength = 14; - - var expectedItems = new byte?[] - { - 0, 2, 6, 3, 91, byte.MaxValue, 71, 5, 71, 52, null, 211, 86, 23 - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromFifteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", "Ten", "Nine", - "Eight", null, "Six", "Five", "Four", "Three", "Two", "One"); - - const int expectedLength = 15; - - var expectedItems = new[] - { - "Fifteen", "Fourteen", "Thirteen", "Twelve", "Eleven", "Ten", "Nine", - "Eight", null, "Six", "Five", "Four", "Three", "Two", "One" - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSixteenItems_ExpectInnerStateIsSourceItems() - { - var actual = FlatArray.From( - decimal.MinusOne, 178.81m, 24, -75195.71m, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m); - - const int expectedLength = 16; - - var expectedItems = new[] - { - decimal.MinusOne, 178.81m, 24, -75195.71m, decimal.Zero, 75, 168, -300.9m, - 9005, decimal.MaxValue, 198234.71m, decimal.One, decimal.MinValue, 7, -191, -275000.01m - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.Span.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.Span.cs deleted file mode 100644 index ea9386f..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.Span.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayStaticTest -{ - [Fact] - public void FromReadOnlySpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = default(ReadOnlySpan); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(true)] - [InlineData(null, false, true)] - public void FromReadOnlySpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params bool?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = new ReadOnlySpan(sourceItems); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromSpan_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = default(Span); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromSpan_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - Span source = stackalloc byte?[] { 115, 0, byte.MaxValue, 215 }; - var actual = FlatArray.From(source); - - const int expectedLength = 4; - var expectedItems = new byte?[] { 115, 0, byte.MaxValue, 215 }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromSpan_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceItems = new[] - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, PlusFifteenIdLowerSomeStringNameRecord - }; - - var source = sourceItems.AsSpan(); - var actual = FlatArray.From(source); - - source[1] = PlusFifteenIdSomeStringNameRecord; - - var expectedItems = new[] - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, PlusFifteenIdLowerSomeStringNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.cs deleted file mode 100644 index 7fb1ba2..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArray/Test.From.cs +++ /dev/null @@ -1,366 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayStaticTest -{ - [Fact] - public void FromArray_SourceIsNull_ExpectInnerStateIsDefault() - { - StructType[]? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromArray_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(Zero)] - [InlineData(PlusFifteen, null, MinusFifteen, PlusFifteen)] - [InlineData(12, 15, 1, 91, 7, -95, null, 0, 5, 6, 7, 901, 98, -266, 78, 62, 21, 35, 75, 212, 51)] - public void FromArray_SourceIsNotEmpty_ExpectInnerStateIsSourceArray( - params int?[] source) - { - var coppied = source.GetCopy(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromArray_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceArray = new[] { "One", "Two", "Three" }; - var actual = FlatArray.From(sourceArray); - - sourceArray[1] = "2"; - var expectedItems = new[] { "One", "Two", "Three" }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(FlatArray); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(LowerSomeString, TabString, SomeString, EmptyString, WhiteSpaceString)] - public void FromFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray( - params string[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.InitializeFlatArray(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNull_ExpectInnerStateIsDefault() - { - var source = default(FlatArray?); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - FlatArray? source = default(FlatArray); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableFlatArray_SourceIsNotDefault_ExpectInnerStateIsSourceArray() - { - FlatArray? source = new[] { SomeString, AnotherString, TabString }.InitializeFlatArray(2); - - var actual = FlatArray.From(source); - var expectedItems = new[] { SomeString, AnotherString }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromList_SourceIsNull_ExpectInnerStateIsDefault() - { - List? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new List(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromList_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var source = new List - { - MinusFifteenIdRefType, ZeroIdRefType - }; - - var actual = FlatArray.From(source); - - const int expectedLength = 2; - var expectedItems = new[] - { - MinusFifteenIdRefType, ZeroIdRefType - }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void FromList_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - var actual = FlatArray.From(sourceList); - - sourceList[0] = PlusFifteenIdLowerSomeStringNameRecord; - sourceList.Add(MinusFifteenIdNullNameRecord); - - var expectedItems = new[] - { - MinusFifteenIdSomeStringNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - var source = default(ImmutableArray); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData(LowerSomeString, null, AnotherString)] - public void FromImmutableArray_SourceIsNotDefault_ExpectInnerStateAreSourceItems( - params string?[] sourceArray) - { - var coppied = sourceArray.GetCopy(); - - var source = sourceArray.ToImmutableArray(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsNull_ExpectInnerStateIsDefault() - { - ImmutableArray? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromNullableImmutableArray_SourceIsDefault_ExpectInnerStateIsDefault() - { - ImmutableArray? source = new ImmutableArray();; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(One)] - [InlineData(MinusFifteen, Zero, PlusFifteen)] - public void FromNullableImmutableArray_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params int[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = sourceItems.ToImmutableArray(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - } - - [Fact] - public void FromEnumerable_SourceIsNull_ExpectInnerStateIsDefault() - { - IEnumerable? source = null; - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromEnumerable_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = Enumerable.Empty(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(SomeString)] - [InlineData("01", "02", "03", "04", "05", "06", null, "08", "09", "10", "11", "12")] - public void FromEnumerable_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params string?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = GetSource(); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(coppied, coppied.Length); - - IEnumerable GetSource() - { - foreach (var item in sourceItems) - { - yield return item; - } - } - } - - [Fact] - public void FromCollection_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new StubCollection(new()); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromCollection_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new List - { - SomeTextRecordStruct, default, AnotherTextRecordStruct - }; - - var source = new StubCollection(sourceItems); - var actual = FlatArray.From(source); - - var expectedItems = new[] - { - SomeTextRecordStruct, default, AnotherTextRecordStruct - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromCollection_ThanModifySource_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - null, SomeTextStructType - }; - - var source = new StubCollection(sourceList); - var actual = FlatArray.From(source); - - source.Remove(SomeTextStructType); - - var expectedItems = new StructType?[] - { - null, SomeTextStructType - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromReadOnlyList_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var source = new StubReadOnlyList(new()); - var actual = FlatArray.From(source); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromReadOnlyList_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new List - { - SomeTextRecordStruct, AnotherTextRecordStruct, UpperAnotherTextRecordStruct - }; - - var source = new StubCollection(sourceItems); - var actual = FlatArray.From(source); - - var expectedItems = new[] - { - SomeTextRecordStruct, AnotherTextRecordStruct, UpperAnotherTextRecordStruct - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void FromReadOnlyCollection_SourceIsEmpty_ExpectInnerStateIsDefault() - { - var sourceItems = Array.Empty(); - var source = new StubReadOnlyCollection(sourceItems); - - var actual = FlatArray.From(source); - actual.VerifyInnerState(default, default); - } - - [Fact] - public void FromReadOnlyCollection_SourceIsNotEmpty_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] - { - ZeroIdRefType, PlusFifteenIdRefType - }; - - var source = new StubReadOnlyCollection(sourceItems); - var actual = FlatArray.From(source); - - var expectedItems = new[] - { - ZeroIdRefType, PlusFifteenIdRefType - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/FlatArrayExtensionsTest.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/FlatArrayExtensionsTest.cs deleted file mode 100644 index 23cba67..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/FlatArrayExtensionsTest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Collections.Tests; - -public sealed partial class FlatArrayExtensionsTest -{ -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Array.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Array.cs deleted file mode 100644 index d96dedb..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Array.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsNullArray_ExpectInnerStateIsDefault() - { - RecordStruct[]? source = null; - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsEmptyArray_ExpectInnerStateIsDefault() - { - var source = Array.Empty(); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptyArray_ExpectInnerStateIsSourceArray() - { - var source = new[] { MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord }; - - var actual = source.ToFlatArray(); - var expectedItems = new[] { MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, PlusFifteenIdSomeStringNameRecord }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ToFlatArray_ThanModifySourceArray_ExpectInnerStateHasNotChanged() - { - var source = new[] { default, SomeTextStructType }; - var actual = source.ToFlatArray(); - - source[0] = LowerSomeTextStructType; - var expectedItems = new[] { default, SomeTextStructType }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Enumerable.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Enumerable.cs deleted file mode 100644 index c9e47c0..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Enumerable.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsNullEnumerable_ExpectInnerStateIsDefault() - { - IEnumerable? source = null; - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsEmptyEnumerable_ExpectInnerStateIsDefault() - { - var source = Enumerable.Empty(); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Theory] - [InlineData(PlusFifteen)] - [InlineData(27, null, 34, -18, 191)] - public void ToFlatArray_FromEnumerable_SourceIsNotEmpty_ExpectInnerStateAreSourceItems( - params int?[] sourceItems) - { - var coppied = sourceItems.GetCopy(); - - var source = GetSource(); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(coppied, coppied.Length); - - IEnumerable GetSource() - { - foreach (var item in sourceItems) - { - yield return item; - } - } - } - - [Fact] - public void ToFlatArray_SourceIsEmptyCollection_ExpectInnerStateIsDefault() - { - var source = new StubCollection(new()); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptyCollection_ExpectInnerStateAreSourceItems() - { - var sourceItems = new List - { - SomeTextStructType, null - }; - - var source = new StubCollection(sourceItems); - var actual = source.ToFlatArray(); - - var expectedItems = new StructType?[] - { - SomeTextStructType, null - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ToFlatArray_ThanModifySourceCollection_ExpectInnerStateHasNotChanged() - { - var sourceList = new List - { - MinusFifteenIdRefType, ZeroIdRefType, PlusFifteenIdRefType - }; - - var source = new StubCollection(sourceList); - var actual = source.ToFlatArray(); - - source.Add(new()); - - var expectedItems = new[] - { - MinusFifteenIdRefType, ZeroIdRefType, PlusFifteenIdRefType - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ToFlatArray_SourceIsEmptyReadOnlyList_ExpectInnerStateIsDefault() - { - var source = new StubReadOnlyList(new()); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptyReadOnlyList_ExpectInnerStateAreSourceItems() - { - var sourceItems = new List - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, MinusFifteenIdSomeStringNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - var source = new StubCollection(sourceItems); - var actual = source.ToFlatArray(); - - var expectedItems = new[] - { - MinusFifteenIdNullNameRecord, ZeroIdNullNameRecord, MinusFifteenIdSomeStringNameRecord, PlusFifteenIdSomeStringNameRecord - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ToFlatArray_SourceIsEmptyReadOnlyCollection_ExpectInnerStateIsDefault() - { - var sourceItems = Array.Empty(); - var source = new StubReadOnlyCollection(sourceItems); - - var actual = source.ToFlatArray(); - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptyReadOnlyCollection_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] - { - EmptyString, SomeString, null, UpperAnotherString, AnotherString - }; - - var source = new StubReadOnlyCollection(sourceItems); - var actual = source.ToFlatArray(); - - var expectedItems = new[] - { - EmptyString, SomeString, null, UpperAnotherString, AnotherString - }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.FlatArray.Nullable.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.FlatArray.Nullable.cs deleted file mode 100644 index 1054d83..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.FlatArray.Nullable.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsNullFlatArray_ExpectInnerStateIsDefault() - { - var source = default(FlatArray?); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNullableDefaultFlatArray_ExpectInnerStateIsDefault() - { - FlatArray? source = default(FlatArray); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotNullableDefaultFlatArray_ExpectInnerStateIsSourceArray() - { - FlatArray? source = new[] { MinusFifteenIdRefType, PlusFifteenIdRefType }.InitializeFlatArray(); - - var actual = source.ToFlatArray(); - var expectedItems = new[] { MinusFifteenIdRefType, PlusFifteenIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.FlatArray.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.FlatArray.cs deleted file mode 100644 index 2d92afc..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.FlatArray.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsDefaultFlatArray_ExpectInnerStateIsDefault() - { - var source = default(FlatArray); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotDefaultFlatArray_ExpectInnerStateIsSourceArray() - { - var source = new FlatArray(MinusFifteenIdNullNameRecord, null, ZeroIdNullNameRecord); - - var actual = source.ToFlatArray(); - var expectedItems = new[] { MinusFifteenIdNullNameRecord, null, ZeroIdNullNameRecord }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ImmutableArray.Nullable.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ImmutableArray.Nullable.cs deleted file mode 100644 index 6e0f2db..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ImmutableArray.Nullable.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Immutable; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsNullImmutableArray_ExpectInnerStateIsDefault() - { - ImmutableArray? source = null; - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNullableDefaultImmutableArray_ExpectInnerStateIsDefault() - { - ImmutableArray? source = new ImmutableArray();; - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotNullableDefaultImmutableArray_ExpectInnerStateAreSourceItems() - { - ImmutableArray? source = new[] { MinusFifteen, One, Zero, PlusFifteen }.ToImmutableArray(); - - var actual = source.ToFlatArray(); - var expectedItems = new[] { MinusFifteen, One, Zero, PlusFifteen }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ImmutableArray.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ImmutableArray.cs deleted file mode 100644 index f4a490a..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ImmutableArray.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Immutable; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsDefaultImmutableArray_ExpectInnerStateIsDefault() - { - var source = default(ImmutableArray); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotDefaultImmutableArray_ExpectInnerStateAreSourceItems() - { - var source = new[] { MinusFifteenIdRefType, null, PlusFifteenIdRefType }.ToImmutableArray(); - - var actual = source.ToFlatArray(); - var expectedItems = new[] { MinusFifteenIdRefType, null, PlusFifteenIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.List.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.List.cs deleted file mode 100644 index 09a5984..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.List.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsNullList_ExpectInnerStateIsDefault() - { - List? source = null; - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsEmptyList_ExpectInnerStateIsDefault() - { - var source = new List(); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptyList_ExpectInnerStateAreSourceItems() - { - var source = new List { SomeString, AnotherString }; - var actual = source.ToFlatArray(); - - const int expectedLength = 2; - var expectedItems = new[] { SomeString, AnotherString }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } - - [Fact] - public void ToFlatArray_ThanModifySourceList_ExpectInnerStateHasNotChanged() - { - var sourceList = new List { SomeString, null, MinusFifteenIdRefType, Zero }; - var actual = sourceList.ToFlatArray(); - - sourceList[2] = ZeroIdNullNameRecord; - sourceList.Add(long.MaxValue); - - const int expectedLength = 4; - var expectedItems = new object?[] { SomeString, null, MinusFifteenIdRefType, Zero }; - - actual.VerifyInnerState(expectedItems, expectedLength); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ReadOnlySpan.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ReadOnlySpan.cs deleted file mode 100644 index 7d65ee0..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.ReadOnlySpan.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsEmptyReadOnlySpan_ExpectInnerStateIsDefault() - { - var source = default(ReadOnlySpan); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptyReadOnlySpan_ExpectInnerStateAreSourceItems() - { - var sourceItems = new[] { MinusFifteenIdRefType, null, ZeroIdRefType, PlusFifteenIdRefType }; - var source = new ReadOnlySpan(sourceItems); - - var actual = source.ToFlatArray(); - var expectedItems = new[] { MinusFifteenIdRefType, null, ZeroIdRefType, PlusFifteenIdRefType }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Span.cs b/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Span.cs deleted file mode 100644 index 43d4936..0000000 --- a/src/collections-flat-array/Collections.FlatArray.Tests/Tests.FlatArrayExtensions/Test.ToFlatArray.Span.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Linq; -using PrimeFuncPack.UnitTest; -using Xunit; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Collections.Tests; - -partial class FlatArrayExtensionsTest -{ - [Fact] - public void ToFlatArray_SourceIsEmptySpan_ExpectInnerStateIsDefault() - { - var source = default(Span); - var actual = source.ToFlatArray(); - - actual.VerifyInnerState(default, default); - } - - [Fact] - public void ToFlatArray_SourceIsNotEmptySpan_ExpectInnerStateAreSourceItems() - { - var source = new[] { SomeTextRecordStruct, AnotherTextRecordStruct }.AsSpan(); - - var actual = source.ToFlatArray(); - var expectedItems = new[] { SomeTextRecordStruct, AnotherTextRecordStruct }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } - - [Fact] - public void ToFlatArray_ThanModifySourceSpan_ExpectInnerStateHasNotChanged() - { - var source = new int?[] { MinusFifteen, Zero, One, null, MinusOne, PlusFifteen }.AsSpan(); - var actual = source.ToFlatArray(); - - source[4] += 1; - var expectedItems = new int?[] { MinusFifteen, Zero, One, null, MinusOne, PlusFifteen }; - - actual.VerifyInnerState(expectedItems, expectedItems.Length); - } -} \ No newline at end of file diff --git a/src/collections-flat-array/Collections.FlatArray/Collections.FlatArray.csproj b/src/collections-flat-array/Collections.FlatArray/Collections.FlatArray.csproj deleted file mode 100644 index 87fa49d..0000000 --- a/src/collections-flat-array/Collections.FlatArray/Collections.FlatArray.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - net6.0 - disable - enable - true - true - true - LICENSE - README.md - https://github.com/pfpack/pfpack-collections - https://github.com/pfpack/pfpack-collections - pfpack - Andrei Sergeev, Pavel Moskovoy - Copyright © 2022 Andrei Sergeev, Pavel Moskovoy - PrimeFuncPack Collections.FlatArray is a core library for .NET consisting of immutable FlatArray. - System.Collections.Generic - EarlyFuncPack.Collections.FlatArray - 0.11.0 - - - - - True - - - - True - - - - - diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.1_16.cs deleted file mode 100644 index 8e6f2bd..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.1_16.cs +++ /dev/null @@ -1,359 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial class FlatArray -{ - partial class Builder - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From(T item0) - => - new(item0); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1) - => - new( - item0, - item1); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2) - => - new( - item0, - item1, - item2); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3) - => - new( - item0, - item1, - item2, - item3); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4) - => - new( - item0, - item1, - item2, - item3, - item4); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5) - => - new( - item0, - item1, - item2, - item3, - item4, - item5); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray.Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14, - T item15) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14, - item15); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.Span.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.Span.cs deleted file mode 100644 index a7e6f45..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.Span.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace System.Collections.Generic; - -partial class FlatArray -{ - partial class Builder - { - public static FlatArray.Builder From(ReadOnlySpan source) - => - FlatArray.Builder.From(source); - - public static FlatArray.Builder From(Span source) - => - FlatArray.Builder.From(source); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.cs deleted file mode 100644 index de54d34..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.Factory.From.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial class FlatArray -{ - partial class Builder - { - public static FlatArray.Builder From([AllowNull] params T[] source) - => - FlatArray.Builder.From(source); - - public static FlatArray.Builder From(FlatArray source) - => - FlatArray.Builder.From(source); - - public static FlatArray.Builder From(FlatArray? source) - => - FlatArray.Builder.From(source); - - public static FlatArray.Builder From([AllowNull] List source) - => - FlatArray.Builder.From(source); - - public static FlatArray.Builder From(ImmutableArray source) - => - FlatArray.Builder.From(source); - - public static FlatArray.Builder From(ImmutableArray? source) - => - FlatArray.Builder.From(source); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.cs deleted file mode 100644 index 6de3ed8..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.Builder/FlatArray.Builder.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System.Collections.Generic; - -partial class FlatArray -{ - public static partial class Builder - { - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Clear.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Clear.cs deleted file mode 100644 index d330bbe..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Clear.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - // TODO: Make public when dynamic builder is implemented - internal void Clear() - => - this = default; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Empty.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Empty.cs deleted file mode 100644 index 2d8d259..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Empty.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - // TODO: Make public when dynamic builder is implemented - internal static Builder Empty() - => - default; - - // TODO: Make public when dynamic builder is implemented - internal static Builder Empty(int capacity) - { - if (capacity is not >= 0) - { - throw InnerExceptionFactory.CapacityOutOfRange_MustBeGreaterThanOrEqualToZero(nameof(capacity), capacity); - } - - if (capacity == default) - { - return default; - } - - // TODO: Implement dynamic builder - throw new NotImplementedException(); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Enumerator.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Enumerator.cs deleted file mode 100644 index 75af9f8..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Enumerator.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public ref struct Enumerator - { - private const int DefaultIndex = -1; - - private readonly Builder builder; - - private int index; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal Enumerator(Builder builder) - { - this.builder = builder; - index = DefaultIndex; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool MoveNext() - { - if (index < builder.length) - { - if (++index < builder.length) - { - return true; - } - } - - return false; - } - - public ref T Current - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - if (index >= 0 && index < builder.length) - { - return ref builder.items![index]; - } - - // The builder length may have changed since the last successful MoveNext - // Thus, throw IndexOutOfRangeException instead of InvalidOperationException - throw InnerExceptionFactory.IndexOutOfRange(nameof(index), index); - } - } - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Equality.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Equality.cs deleted file mode 100644 index 12c7764..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Equality.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - // The Builder Equality implements a reference-based comparison - - public bool Equals(Builder other) - => - length == other.length && - ReferenceEquals(items, other.items); - - public static bool Equals(Builder left, Builder right) - => - left.Equals(right); - - public static bool operator ==(Builder left, Builder right) - => - left.Equals(right); - - public static bool operator !=(Builder left, Builder right) - => - left.Equals(right) is not true; - - // This method is not supported as ref structs cannot be boxed - [Obsolete(EqualsNotSupportedMessage, error: true)] - [DoesNotReturn] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member - public override bool Equals([NotNullWhen(true)] object? obj) -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member - => - throw new NotSupportedException(EqualsNotSupportedMessage); - - // This method is not supported as ref structs cannot be boxed - [Obsolete(GetHashCodeNotSupportedMessage, error: true)] - [DoesNotReturn] -#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member - public override int GetHashCode() -#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member - => - throw new NotSupportedException(GetHashCodeNotSupportedMessage); - - private const string EqualsNotSupportedMessage - = - "Equals(Object) on FlatArray.Builder is not supported. Use the Equals(Builder) instead."; - - private const string GetHashCodeNotSupportedMessage - = - "GetHashCode() on FlatArray.Builder is not supported."; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.1_16.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.1_16.cs deleted file mode 100644 index 0ce4b26..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.1_16.cs +++ /dev/null @@ -1,470 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder(T item) - { - var items = new[] { item }; - Debug.Assert(items.Length == 1); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1) - { - var items = new[] - { - item0, - item1 - }; - Debug.Assert(items.Length == 2); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2) - { - var items = new[] - { - item0, - item1, - item2 - }; - Debug.Assert(items.Length == 3); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3) - { - var items = new[] - { - item0, - item1, - item2, - item3 - }; - Debug.Assert(items.Length == 4); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4 - }; - Debug.Assert(items.Length == 5); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5 - }; - Debug.Assert(items.Length == 6); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6 - }; - Debug.Assert(items.Length == 7); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7 - }; - Debug.Assert(items.Length == 8); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8 - }; - Debug.Assert(items.Length == 9); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9 - }; - Debug.Assert(items.Length == 10); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10 - }; - Debug.Assert(items.Length == 11); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11 - }; - Debug.Assert(items.Length == 12); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12 - }; - Debug.Assert(items.Length == 13); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13 - }; - Debug.Assert(items.Length == 14); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14 - }; - Debug.Assert(items.Length == 15); - - length = items.Length; - this.items = items; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14, - T item15) - { - var items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14, - item15 - }; - Debug.Assert(items.Length == 16); - - length = items.Length; - this.items = items; - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.Private.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.Private.cs deleted file mode 100644 index d2c2eba..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.Private.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - // Initializes an instance in 'as is' mode without any processing and creation of a defensive copy - // - // Since the invariant of Builder implies the empty Builder contains null underlying array, - // the caller MUST ensure the length is GREATER than zero - // - // Note: The unused arg is intended to separate this from the public one - // - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Builder(T[] items, int _) - { - Debug.Assert(items.Length != default); - - length = items.Length; - this.items = items; - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.cs deleted file mode 100644 index 6c0e600..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.Constructor.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Builder([AllowNull] params T[] source) - { - if (source is null || source.Length == default) - { - this = default; - return; - } - - length = source.Length; - items = InnerArrayHelper.Clone(source); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.1_16.cs deleted file mode 100644 index 3a237d3..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.1_16.cs +++ /dev/null @@ -1,359 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From(T item0) - => - new(item0); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1) - => - new( - item0, - item1); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2) - => - new( - item0, - item1, - item2); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3) - => - new( - item0, - item1, - item2, - item3); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4) - => - new( - item0, - item1, - item2, - item3, - item4); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5) - => - new( - item0, - item1, - item2, - item3, - item4, - item5); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Builder From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14, - T item15) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14, - item15); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.Span.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.Span.cs deleted file mode 100644 index d44e35e..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.Span.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public static Builder From(ReadOnlySpan source) - => - source.IsEmpty ? default : new(source.ToArray(), default); - - public static Builder From(Span source) - => - source.IsEmpty ? default : new(source.ToArray(), default); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.cs deleted file mode 100644 index f958038..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.From.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public static Builder From([AllowNull] params T[] source) - => - source is null ? default : InnerFromArray(source); - - public static Builder From(FlatArray source) - => - InnerFromFlatArray(source); - - public static Builder From(FlatArray? source) - => - source is null ? default : InnerFromFlatArray(source.Value); - - public static Builder From([AllowNull] List source) - => - source is null ? default : InnerFromList(source); - - public static Builder From(ImmutableArray source) - => - InnerFromImmutableArray(source); - - public static Builder From(ImmutableArray? source) - => - source is null ? default : InnerFromImmutableArray(source.Value); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Builder InnerFromArray(T[] source) - => - source.Length == default ? default : new(InnerArrayHelper.Clone(source), default); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Builder InnerFromFlatArray(FlatArray source) - => - source.InnerIsNotEmpty ? new(InnerArrayHelper.Copy(source.items, source.length), default) : default; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Builder InnerFromList(List source) - { - var count = source.Count; - if (count == default) - { - return default; - } - - var array = new T[count]; - source.CopyTo(array, 0); - - return new(array, default); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Builder InnerFromImmutableArray(ImmutableArray source) - { - if (source.IsDefaultOrEmpty) - { - return default; - } - - var array = new T[source.Length]; - source.CopyTo(array, 0); - - return new(array, default); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.OfLength.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.OfLength.cs deleted file mode 100644 index c4ead5b..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Factory.OfLength.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public static Builder OfLength(int length) - { - if (length is not >= 0) - { - throw InnerExceptionFactory.LengthOutOfRange(nameof(length), length); - } - - return length == default ? default : new(new T[length], default); - } - - // TODO: Make public when dynamic builder is implemented - internal static Builder OfLength(int length, int capacity) - { - if (length is not >= 0) - { - throw InnerExceptionFactory.LengthOutOfRange(nameof(length), length); - } - - if (capacity >= length is not true) - { - throw InnerExceptionFactory.CapacityOutOfRange_MustBeGreaterThanOrEqualToLength(nameof(capacity), capacity, length: length); - } - - // TODO: Implement dynamic builder - throw new NotImplementedException(); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Fill.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Fill.cs deleted file mode 100644 index c7de119..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Fill.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public void Fill() - { - if (InnerIsEmpty) - { - return; - } - - // Array.Clear implementation uses Span.Clear - // Thus, direct using Span should be more efficient - - // Fills the items by their default values - InnerAsSpan().Clear(); - } - - public void Fill(T value) - { - if (InnerIsEmpty) - { - return; - } - - // Array.Fill implementation uses Span.Fill - // Thus, direct using Span should be more efficient - - InnerAsSpan().Fill(value); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.GetEnumerator.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.GetEnumerator.cs deleted file mode 100644 index 6867a79..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.GetEnumerator.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public Enumerator GetEnumerator() - => - new(this); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Indexer.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Indexer.cs deleted file mode 100644 index 2e29bf0..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.Indexer.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public ref T this[int index] - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - if (index >= 0 && index < length) - { - return ref items![index]; - } - - throw InnerExceptionFactory.IndexOutOfRange(nameof(index), index); - } - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.MoveToArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.MoveToArray.cs deleted file mode 100644 index 034dbbd..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.MoveToArray.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public FlatArray MoveToArray() - { - if (InnerIsEmpty) - { - return default; - } - - var length = this.length; - var items = this.items; - - // Clear the builder before moving the items to the result array - this = default; - - return new(length, items); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.ToArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.ToArray.cs deleted file mode 100644 index 7eeb7e0..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.ToArray.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - // TODO: Make public when dynamic builder is implemented - internal FlatArray ToArray() - => - InnerIsNotEmpty ? new(InnerArrayHelper.Copy(items, length), default) : default; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.ToString.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.ToString.cs deleted file mode 100644 index 34a3b68..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.ToString.cs +++ /dev/null @@ -1,13 +0,0 @@ -using static System.FormattableString; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial struct Builder - { - public override string ToString() - => - Invariant($"FlatArray<{typeof(T).Name}>.Builder[{Length}]"); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.cs deleted file mode 100644 index 0b168c7..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.Builder/FlatArray.Builder.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - [DebuggerDisplay($"{nameof(Length)} = {{{nameof(Length)}}}")] - public ref partial struct Builder - { - private readonly int length; - - private readonly T[]? items; - - public int Length - => - length; - - public bool IsNotEmpty - => - length != default; - - public bool IsEmpty - => - length == default; - - [MemberNotNullWhen(returnValue: true, nameof(items))] - private bool InnerIsNotEmpty - => - length != default; - - [MemberNotNullWhen(returnValue: false, nameof(items))] - private bool InnerIsEmpty - => - length == default; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Span InnerAsSpan() - => - InnerIsNotEmpty ? new(items, 0, length) : Span.Empty; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.Impl.NotSupported.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.Impl.NotSupported.cs deleted file mode 100644 index d39cc76..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.Impl.NotSupported.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFlatList - { - [DoesNotReturn] - void ICollection.Add(T item) - => - throw InnerExceptionFactory.NotSupportedOnReadOnlyArray(); - - [DoesNotReturn] - void IList.Insert(int index, T item) - => - throw InnerExceptionFactory.NotSupportedOnReadOnlyArray(); - - [DoesNotReturn] - bool ICollection.Remove(T item) - => - throw InnerExceptionFactory.NotSupportedOnReadOnlyArray(); - - [DoesNotReturn] - void IList.RemoveAt(int index) - => - throw InnerExceptionFactory.NotSupportedOnReadOnlyArray(); - - [DoesNotReturn] - void ICollection.Clear() - => - throw InnerExceptionFactory.NotSupportedOnReadOnlyArray(); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.Impl.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.Impl.cs deleted file mode 100644 index f40a80a..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.Impl.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFlatList - { - public bool IsReadOnly => true; - - public int Count => length; - - public T this[int index] - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - if (index >= 0 && index < length) - { - return items[index]; - } - - throw InnerExceptionFactory.IndexOutOfRange(nameof(index), index); - } - set - { - throw InnerExceptionFactory.NotSupportedOnReadOnlyArray(); - } - } - - public int IndexOf(T item) - => - Array.IndexOf(items, item, 0, length); - - public bool Contains(T item) - => - Array.IndexOf(items, item, 0, length) >= 0; - - public void CopyTo(T[] array, int arrayIndex) - => - // Delegate null and range checks to Array.Copy - Array.Copy(items, 0, array, arrayIndex, length); - - public IEnumerator GetEnumerator() - => - new InnerEnumerator(length, items); - - IEnumerator IEnumerable.GetEnumerator() - => - GetEnumerator(); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.InnerEnumerator.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.InnerEnumerator.cs deleted file mode 100644 index 9b6ebf7..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.InnerEnumerator.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFlatList - { - private sealed class InnerEnumerator : IEnumerator - { - private const int DefaultIndex = -1; - - private readonly int length; - - private readonly T[] items; - - private int index; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal InnerEnumerator(int length, T[] items) - { - Debug.Assert(length >= 0 && length <= items.Length); - - this.length = length; - this.items = items; - index = DefaultIndex; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool MoveNext() - { - if (index < length) - { - if (++index < length) - { - return true; - } - } - - return false; - } - - public T Current - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - if (index >= 0 && index < length) - { - return items[index]; - } - - throw InnerExceptionFactory.EnumerationEitherNotStartedOrFinished(); - } - } - - object IEnumerator.Current => Current!; - - public void Reset() => index = DefaultIndex; - - public void Dispose() { } - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.cs deleted file mode 100644 index ccdf74f..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T.InnerFlatList/FlatArray.InnerFlatList.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Diagnostics; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - private sealed partial class InnerFlatList : IList, IReadOnlyList - { - private readonly int length; - - private readonly T[] items; - - internal InnerFlatList(int length, T[] items) - { - Debug.Assert(length >= 0 && length <= items.Length); - - this.length = length; - this.items = items; - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.AsEnumerable.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.AsEnumerable.cs deleted file mode 100644 index 0077e07..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.AsEnumerable.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public IEnumerable AsEnumerable() - => - new InnerFlatList(length, InnerItems()); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.AsSpanOrMemory.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.AsSpanOrMemory.cs deleted file mode 100644 index 7c34d29..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.AsSpanOrMemory.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public ReadOnlySpan AsSpan() - => - InnerAsSpan(); - - public ReadOnlyMemory AsMemory() - => - InnerAsMemory(); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Clone.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Clone.cs deleted file mode 100644 index e84b8a8..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Clone.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public FlatArray Clone() - => - InnerClone(); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private FlatArray InnerClone() - => - InnerIsNotEmpty ? new(InnerArrayHelper.Copy(items, length), default) : default; -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Enumerator.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Enumerator.cs deleted file mode 100644 index 212876a..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Enumerator.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public ref struct Enumerator - { - private const int DefaultIndex = -1; - - private readonly ReadOnlySpan items; - - private int index; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal Enumerator(ReadOnlySpan items) - { - this.items = items; - index = DefaultIndex; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool MoveNext() - { - if (index < items.Length) - { - if (++index < items.Length) - { - return true; - } - } - - return false; - } - - public ref readonly T Current - { - // Delegate range check to the indexer for performance purposes - // IndexOutOfRangeException will be thrown instead of InvalidOperationException - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => ref items[index]; - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Equality.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Equality.cs deleted file mode 100644 index 934feb8..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Equality.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static bool Equals(FlatArray left, FlatArray right) - => - left.Equals(right); - - public static bool operator ==(FlatArray left, FlatArray right) - => - left.Equals(right); - - public static bool operator !=(FlatArray left, FlatArray right) - => - left.Equals(right) is not true; - - public override bool Equals([NotNullWhen(true)] object? obj) - => - obj is FlatArray other && - Equals(other); - - public bool Equals(FlatArray other) - { - if (length != other.length) - { - return false; - } - - if (length == default) - { - return true; - } - - if (ReferenceEquals(items, other.items)) - { - return true; - } - - for (int i = 0; i < length; i++) - { - if (InnerItemComparer.Value.Equals(items![i], other.items![i])) - { - continue; - } - return false; - } - - return true; - } - - public override int GetHashCode() - { - HashCode builder = new(); - - builder.Add(EqualityContractComparer.GetHashCode(EqualityContract)); - - for (int i = 0; i < length; i++) - { - var item = items![i]; - builder.Add(item is null ? default : InnerItemComparer.Value.GetHashCode(item)); - } - - return builder.ToHashCode(); - } - - private static Type EqualityContract - => - typeof(FlatArray); - - private static EqualityComparer EqualityContractComparer - => - EqualityComparer.Default; - - private static class InnerItemComparer - { - internal static readonly EqualityComparer Value = EqualityComparer.Default; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.EqualityComparer.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.EqualityComparer.cs deleted file mode 100644 index 71ebfac..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.EqualityComparer.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public sealed class EqualityComparer : IEqualityComparer> - { - private readonly IEqualityComparer comparer; - - private EqualityComparer(IEqualityComparer comparer) - => - this.comparer = comparer; - - public static EqualityComparer Create(IEqualityComparer? comparer) - => - new(comparer ?? EqualityComparer.Default); - - public static EqualityComparer Create() - => - new(EqualityComparer.Default); - - public static EqualityComparer Default - => - InnerDefault.Value; - - public bool Equals(FlatArray x, FlatArray y) - { - if (x.length != y.length) - { - return false; - } - - if (x.length == default) - { - return true; - } - - if (ReferenceEquals(x.items, y.items)) - { - return true; - } - - for (int i = 0; i < x.length; i++) - { - if (comparer.Equals(x.items![i], y.items![i])) - { - continue; - } - return false; - } - - return true; - } - - public int GetHashCode(FlatArray obj) - { - HashCode builder = new(); - - for (int i = 0; i < obj.length; i++) - { - var item = obj.items![i]; - builder.Add(item is null ? default : comparer.GetHashCode(item)); - } - - return builder.ToHashCode(); - } - - private static class InnerDefault - { - internal static readonly EqualityComparer Value = Create(); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.1_16.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.1_16.cs deleted file mode 100644 index 39fe2f1..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.1_16.cs +++ /dev/null @@ -1,467 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray(T item) - { - length = 1; - items = new[] { item }; - - Debug.Assert(length == 1); - Debug.Assert(items.Length == 1); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1) - { - length = 2; - items = new[] - { - item0, - item1 - }; - - Debug.Assert(length == 2); - Debug.Assert(items.Length == 2); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2) - { - length = 3; - items = new[] - { - item0, - item1, - item2 - }; - - Debug.Assert(length == 3); - Debug.Assert(items.Length == 3); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3) - { - length = 4; - items = new[] - { - item0, - item1, - item2, - item3 - }; - - Debug.Assert(length == 4); - Debug.Assert(items.Length == 4); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4) - { - length = 5; - items = new[] - { - item0, - item1, - item2, - item3, - item4 - }; - - Debug.Assert(length == 5); - Debug.Assert(items.Length == 5); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5) - { - length = 6; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5 - }; - - Debug.Assert(length == 6); - Debug.Assert(items.Length == 6); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6) - { - length = 7; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6 - }; - - Debug.Assert(length == 7); - Debug.Assert(items.Length == 7); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7) - { - length = 8; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7 - }; - - Debug.Assert(length == 8); - Debug.Assert(items.Length == 8); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8) - { - length = 9; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8 - }; - - Debug.Assert(length == 9); - Debug.Assert(items.Length == 9); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9) - { - length = 10; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9 - }; - - Debug.Assert(length == 10); - Debug.Assert(items.Length == 10); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10) - { - length = 11; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10 - }; - - Debug.Assert(length == 11); - Debug.Assert(items.Length == 11); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11) - { - length = 12; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11 - }; - - Debug.Assert(length == 12); - Debug.Assert(items.Length == 12); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12) - { - length = 13; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12 - }; - - Debug.Assert(length == 13); - Debug.Assert(items.Length == 13); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13) - { - length = 14; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13 - }; - - Debug.Assert(length == 14); - Debug.Assert(items.Length == 14); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14) - { - length = 15; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14 - }; - - Debug.Assert(length == 15); - Debug.Assert(items.Length == 15); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14, - T item15) - { - length = 16; - items = new[] - { - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14, - item15 - }; - - Debug.Assert(length == 16); - Debug.Assert(items.Length == 16); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.Private.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.Private.cs deleted file mode 100644 index 7801e4f..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.Private.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - // Initializes an instance in 'as is' mode without any processing and creation of a defensive copy - // - // Since the invariant of FlatArray implies the empty FlatArray contains null underlying array, - // the caller MUST ensure the length is GREATER than zero - // - // Note: The unused arg is intended to separate this from the public one - // - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private FlatArray(T[] items, int _) - { - Debug.Assert(items.Length != default); - - length = items.Length; - this.items = items; - } - - // Initializes an instance in 'as is' mode without any processing and creation of a defensive copy - // - // Since the invariant of FlatArray implies the empty FlatArray contains null underlying array, - // the caller MUST ensure the length is GREATER than zero - // - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private FlatArray(int length, T[] items) - { - Debug.Assert(length > 0 && length <= items.Length); - - this.length = length; - this.items = items; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.cs deleted file mode 100644 index a1579de..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Constructor.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FlatArray([AllowNull] params T[] source) - { - if (source is null || source.Length == default) - { - this = default; - return; - } - - length = source.Length; - items = InnerArrayHelper.Clone(source); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.Empty.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.Empty.cs deleted file mode 100644 index 0bd55a7..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.Empty.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static readonly FlatArray Empty; -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.1_16.cs deleted file mode 100644 index 9ed335d..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.1_16.cs +++ /dev/null @@ -1,356 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From(T item0) - => - new(item0); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1) - => - new( - item0, - item1); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2) - => - new( - item0, - item1, - item2); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3) - => - new( - item0, - item1, - item2, - item3); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4) - => - new( - item0, - item1, - item2, - item3, - item4); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5) - => - new( - item0, - item1, - item2, - item3, - item4, - item5); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14, - T item15) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14, - item15); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Span.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Span.cs deleted file mode 100644 index 84b1f50..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.Span.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static FlatArray From(ReadOnlySpan source) - => - source.IsEmpty ? default : new(source.ToArray(), default); - - public static FlatArray From(Span source) - => - source.IsEmpty ? default : new(source.ToArray(), default); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.cs deleted file mode 100644 index fc5da8d..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Explicit.From.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static FlatArray From([AllowNull] params T[] source) - => - source is null ? default : InnerFactory.FromArray(source); - - public static FlatArray From(FlatArray source) - => - InnerFactory.FromFlatArray(source); - - public static FlatArray From(FlatArray? source) - => - source is null ? default : InnerFactory.FromFlatArray(source.Value); - - public static FlatArray From([AllowNull] List source) - => - source is null ? default : InnerFactory.FromList(source); - - public static FlatArray From(ImmutableArray source) - => - InnerFactory.FromImmutableArray(source); - - public static FlatArray From(ImmutableArray? source) - => - source is null ? default : InnerFactory.FromImmutableArray(source.Value); - - public static FlatArray From([AllowNull] IEnumerable source) - => - source switch - { - null => default, - - T[] array - => - InnerFactory.FromArray(array), - - List list - => - InnerFactory.FromList(list), - - FlatArray flatArray - => - InnerFactory.FromFlatArray(flatArray), - - ImmutableArray immutableArray - => - InnerFactory.FromImmutableArray(immutableArray), - - ICollection coll - => - InnerFactory.FromICollection(coll), - - IReadOnlyList list - => - InnerFactory.FromIReadOnlyList(list), - - IReadOnlyCollection coll - => - InnerFactory.FromIEnumerable(coll, coll.Count), - - _ => - InnerFactory.FromIEnumerable(source) - }; -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Implicit.From.Span.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Implicit.From.Span.cs deleted file mode 100644 index a1d138e..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Implicit.From.Span.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static implicit operator FlatArray(ReadOnlySpan source) - => - From(source); - - public static implicit operator FlatArray(Span source) - => - From(source); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Implicit.From.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Implicit.From.cs deleted file mode 100644 index 675282f..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Factory.Implicit.From.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static implicit operator FlatArray([AllowNull] T[] source) - => - From(source); - - public static implicit operator FlatArray([AllowNull] List source) - => - From(source); - - public static implicit operator FlatArray(ImmutableArray source) - => - From(source); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ForEach.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ForEach.cs deleted file mode 100644 index a24c22d..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ForEach.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public void ForEach(Action action) - => - InternalForEach(action ?? throw new ArgumentNullException(nameof(action))); - - public void ForEach(Action action) - => - InnerForEach(action ?? throw new ArgumentNullException(nameof(action))); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void InternalForEach(Action action) - { - for (int i = 0; i < length; i++) - { - action.Invoke(items![i]); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void InnerForEach(Action action) - { - for (int i = 0; i < length; i++) - { - action.Invoke(i, items![i]); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.GetEnumerator.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.GetEnumerator.cs deleted file mode 100644 index f0b6765..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.GetEnumerator.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public Enumerator GetEnumerator() - => - new(InnerAsSpan()); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Indexer.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Indexer.cs deleted file mode 100644 index 82896b0..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.Indexer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public ref readonly T this[int index] - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - if (index >= 0 && index < length) - { - return ref items![index]; - } - - throw InnerExceptionFactory.IndexOutOfRange(nameof(index), index); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToCollection.Explicit.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToCollection.Explicit.cs deleted file mode 100644 index 8809f0d..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToCollection.Explicit.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Collections.Immutable; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public T[] ToArray() - => - InnerIsNotEmpty ? InnerArrayHelper.Copy(items, length) : InnerEmptyArray.OuterValue; - - public List ToList() - { - if (InnerIsEmpty) - { - return new(); - } - - if (length < items.Length) - { - // The most efficient way to build a list for this case - - List result = new(capacity: length); - - for (int i = 0; i < length; i++) - { - result.Add(items[i]); - } - - return result; - } - - return new(items); - } - - public ImmutableArray ToImmutableArray() - { - if (InnerIsEmpty) - { - return ImmutableArray.Empty; - } - - if (length < items.Length) - { - return ImmutableArray.Create(items, 0, length); - } - - return ImmutableArray.Create(items); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToCollection.Implicit.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToCollection.Implicit.cs deleted file mode 100644 index debc5b8..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToCollection.Implicit.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Immutable; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public static implicit operator T[](FlatArray flatArray) - => - flatArray.ToArray(); - - public static implicit operator List(FlatArray flatArray) - => - flatArray.ToList(); - - public static implicit operator ImmutableArray(FlatArray flatArray) - => - flatArray.ToImmutableArray(); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToString.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToString.cs deleted file mode 100644 index 47927de..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.ToString.cs +++ /dev/null @@ -1,10 +0,0 @@ -using static System.FormattableString; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - public override string ToString() - => - Invariant($"FlatArray<{typeof(T).Name}>[{Length}]"); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.cs deleted file mode 100644 index a87d711..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/FlatArray.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Text.Json.Serialization; - -namespace System.Collections.Generic; - -[JsonConverter(typeof(FlatArrayJsonConverterFactory))] -[DebuggerDisplay($"{nameof(Length)} = {{{nameof(Length)}}}")] -public readonly partial struct FlatArray : IEquatable> -{ - private readonly int length; - - private readonly T[]? items; - - public int Length - => - length; - - public bool IsNotEmpty - => - length != default; - - public bool IsEmpty - => - length == default; - - [MemberNotNullWhen(returnValue: true, nameof(items))] - private bool InnerIsNotEmpty - => - length != default; - - [MemberNotNullWhen(returnValue: false, nameof(items))] - private bool InnerIsEmpty - => - length == default; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private T[] InnerItems() - => - InnerIsNotEmpty ? items : InnerEmptyArray.Value; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ReadOnlySpan InnerAsSpan() - => - InnerIsNotEmpty ? new(items, 0, length) : ReadOnlySpan.Empty; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ReadOnlyMemory InnerAsMemory() - => - InnerIsNotEmpty ? new(items, 0, length) : ReadOnlyMemory.Empty; -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerArrayHelper/FlatArray.InnerArrayHelper.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerArrayHelper/FlatArray.InnerArrayHelper.cs deleted file mode 100644 index 9798d70..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerArrayHelper/FlatArray.InnerArrayHelper.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - private static class InnerArrayHelper - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static T[] Clone(T[] source) - { - var dest = new T[source.Length]; - Array.Copy(source, dest, source.Length); - return dest; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static T[] Copy(T[] source, int length) - { - Debug.Assert(length >= 0 && length <= source.Length); - - var dest = new T[length]; - Array.Copy(source, dest, length); - return dest; - } - - // The caller MUST ensure the new size is GREATER than the source size - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void ExtendUnchecked(ref T[] array, int newSize) - { - Debug.Assert(newSize > array.Length); - - var newArray = new T[newSize]; - Array.Copy(array, newArray, array.Length); - array = newArray; - } - - // The caller MUST ensure the new size is LESS than the source size - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static void TruncateUnchecked(ref T[] array, int newSize) - { - Debug.Assert(newSize >= 0 && newSize < array.Length); - - var newArray = new T[newSize]; - Array.Copy(array, newArray, newArray.Length); - array = newArray; - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerEmptyArray/FlatArray.InnerEmptyArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerEmptyArray/FlatArray.InnerEmptyArray.cs deleted file mode 100644 index 3232d37..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerEmptyArray/FlatArray.InnerEmptyArray.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - private static class InnerEmptyArray - { - // Intended for the inner use only, not to pass outside - // Designed to avoid the extra generic instantiation for Array.Empty() - // and not to expose the inner state of an empty FlatArray - -#pragma warning disable CA1825 // Avoid zero-length array allocations - internal static readonly T[] Value = new T[0]; -#pragma warning restore CA1825 // Avoid zero-length array allocations - - // Intended to pass outside, not for the inner use - // Designed to avoid the extra generic instantiation for Array.Empty() - -#pragma warning disable CA1825 // Avoid zero-length array allocations - internal static readonly T[] OuterValue = new T[0]; -#pragma warning restore CA1825 // Avoid zero-length array allocations - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerExceptionFactory/FlatArray.InnerExceptionFactory.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerExceptionFactory/FlatArray.InnerExceptionFactory.cs deleted file mode 100644 index ec2441c..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerExceptionFactory/FlatArray.InnerExceptionFactory.cs +++ /dev/null @@ -1,37 +0,0 @@ -using static System.FormattableString; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - private static class InnerExceptionFactory - { - internal static ArgumentOutOfRangeException LengthOutOfRange(string paramName, int actualValue) - => - new(paramName, Invariant($"Array length must be greater than or equal to zero. Actual value was {actualValue}.")); - - internal static ArgumentOutOfRangeException CapacityOutOfRange_MustBeGreaterThanOrEqualToZero(string paramName, int actualValue) - => - new(paramName, Invariant($"Capacity must be greater than or equal to zero. Actual value was {actualValue}.")); - - internal static ArgumentOutOfRangeException CapacityOutOfRange_MustBeGreaterThanOrEqualToLength(string paramName, int actualValue, int length) - => - new(paramName, Invariant($"Capacity must be greater than or equal to the array length. Actual value was {actualValue}. Length was {length}.")); - - internal static ArgumentOutOfRangeException IndexOutOfRange(string paramName, int actualValue) - => - new(paramName, Invariant($"Index must be greater than or equal to zero and less than the array length. Actual value was {actualValue}.")); - - internal static InvalidOperationException EnumerationEitherNotStartedOrFinished() - => - new("Enumeration has either not started or has already finished."); - - internal static OutOfMemoryException SourceTooLarge() - => - new("The source is too large to allocate."); - - internal static NotSupportedException NotSupportedOnReadOnlyArray() - => - new("The operation is not supported on read-only array."); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromArray.cs deleted file mode 100644 index 3e081a9..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromArray.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromArray(T[] source) - => - source.Length == default ? default : new(InnerArrayHelper.Clone(source), default); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromFlatArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromFlatArray.cs deleted file mode 100644 index be1d3c2..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromFlatArray.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromFlatArray(FlatArray source) - => - source.InnerClone(); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromICollection.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromICollection.cs deleted file mode 100644 index 1b85ab1..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromICollection.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromICollection(ICollection source) - { - var count = source.Count; - if (count is not > 0) - { - return default; - } - - var array = new T[count]; - source.CopyTo(array, 0); - - // Create a defensive copy for an arbitrary ICollection implementation - // that is not as trusted as List or ImmutableArray - var arrayCopy = InnerArrayHelper.Clone(array); - - return new(arrayCopy, default); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromIEnumerable.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromIEnumerable.cs deleted file mode 100644 index cb808b8..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromIEnumerable.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromIEnumerable(IEnumerable source, int estimatedCapacity = default) - { - using var enumerator = source.GetEnumerator(); - - if (enumerator.MoveNext() is not true) - { - return default; - } - - const int defaultCapacity = 4; - - int actualCount = 0; - var array = new T[estimatedCapacity > 0 ? estimatedCapacity : defaultCapacity]; - - do - { - if (actualCount < array.Length) - { - array[actualCount++] = enumerator.Current; - } - else if (actualCount < Array.MaxLength) - { - int newCapacity = InnerEstimateCapacity(array.Length, Array.MaxLength); - InnerArrayHelper.ExtendUnchecked(ref array, newCapacity); - array[actualCount++] = enumerator.Current; - } - else - { - throw InnerExceptionFactory.SourceTooLarge(); - } - } - while (enumerator.MoveNext()); - - if (actualCount < array.Length) - { - InnerArrayHelper.TruncateUnchecked(ref array, actualCount); - } - - return new(array, default); - } - - // The caller MUST ensure the size and the max capacity are GREATER than zero - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static int InnerEstimateCapacity(int size, int maxCapacity) - { - Debug.Assert(size > 0); - Debug.Assert(maxCapacity > 0); - - int capacity = unchecked(size * 2); - - if (capacity < 0) // handle the overflow case - { - return maxCapacity; - } - - if (capacity > maxCapacity) - { - return maxCapacity; - } - - return capacity; - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromIReadOnlyList.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromIReadOnlyList.cs deleted file mode 100644 index df2ef69..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromIReadOnlyList.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromIReadOnlyList(IReadOnlyList source) - { - var count = source.Count; - if (count is not > 0) - { - return default; - } - - int actualCount = 0; - var array = new T[count]; - - do - { - if (actualCount < array.Length) - { - array[actualCount] = source[actualCount]; - } - else - { - InnerArrayHelper.ExtendUnchecked(ref array, count); - array[actualCount] = source[actualCount]; - } - } - while (++actualCount < (count = source.Count)); - - if (actualCount < array.Length) - { - InnerArrayHelper.TruncateUnchecked(ref array, actualCount); - } - - return new(array, default); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromImmutableArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromImmutableArray.cs deleted file mode 100644 index 4bd0ecd..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromImmutableArray.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Immutable; -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromImmutableArray(ImmutableArray source) - { - if (source.IsDefaultOrEmpty) - { - return default; - } - - var array = new T[source.Length]; - source.CopyTo(array, 0); - - return new(array, default); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromList.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromList.cs deleted file mode 100644 index 184b676..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.FromList.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial struct FlatArray -{ - partial class InnerFactory - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static FlatArray FromList(List source) - { - var count = source.Count; - if (count == default) - { - return default; - } - - var array = new T[count]; - source.CopyTo(array, 0); - - return new(array, default); - } - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.cs deleted file mode 100644 index c39924c..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray.T/InnerFactory/FlatArray.InnerFactory.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System.Collections.Generic; - -partial struct FlatArray -{ - private static partial class InnerFactory - { - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Equality.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Equality.cs deleted file mode 100644 index 0ed10f1..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Equality.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System.Collections.Generic; - -partial class FlatArray -{ - public static bool Equals(FlatArray left, FlatArray right) - => - FlatArray.Equals(left, right); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.Empty.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.Empty.cs deleted file mode 100644 index fdf26da..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.Empty.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System.Collections.Generic; - -partial class FlatArray -{ - public static FlatArray Empty() - => - FlatArray.Empty; -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.1_16.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.1_16.cs deleted file mode 100644 index fa756f0..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.1_16.cs +++ /dev/null @@ -1,356 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System.Collections.Generic; - -partial class FlatArray -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From(T item0) - => - new(item0); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1) - => - new( - item0, - item1); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2) - => - new( - item0, - item1, - item2); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3) - => - new( - item0, - item1, - item2, - item3); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4) - => - new( - item0, - item1, - item2, - item3, - item4); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5) - => - new( - item0, - item1, - item2, - item3, - item4, - item5); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FlatArray From( - T item0, - T item1, - T item2, - T item3, - T item4, - T item5, - T item6, - T item7, - T item8, - T item9, - T item10, - T item11, - T item12, - T item13, - T item14, - T item15) - => - new( - item0, - item1, - item2, - item3, - item4, - item5, - item6, - item7, - item8, - item9, - item10, - item11, - item12, - item13, - item14, - item15); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.Span.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.Span.cs deleted file mode 100644 index 5004c51..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.Span.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System.Collections.Generic; - -partial class FlatArray -{ - public static FlatArray From(ReadOnlySpan source) - => - FlatArray.From(source); - - public static FlatArray From(Span source) - => - FlatArray.From(source); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.cs deleted file mode 100644 index 246c297..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.Factory.From.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic; - -partial class FlatArray -{ - public static FlatArray From([AllowNull] params T[] source) - => - FlatArray.From(source); - - public static FlatArray From(FlatArray source) - => - FlatArray.From(source); - - public static FlatArray From(FlatArray? source) - => - FlatArray.From(source); - - public static FlatArray From([AllowNull] List source) - => - FlatArray.From(source); - - public static FlatArray From(ImmutableArray source) - => - FlatArray.From(source); - - public static FlatArray From(ImmutableArray? source) - => - FlatArray.From(source); - - public static FlatArray From([AllowNull] IEnumerable source) - => - FlatArray.From(source); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.cs deleted file mode 100644 index 052954a..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArray/FlatArray.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace System.Collections.Generic; - -public static partial class FlatArray -{ -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/Extensions.ToFlatArray.FromSpan.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/Extensions.ToFlatArray.FromSpan.cs deleted file mode 100644 index 79fe29d..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/Extensions.ToFlatArray.FromSpan.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; - -namespace System.Linq; - -partial class FlatArrayExtensions -{ - public static FlatArray ToFlatArray(this ReadOnlySpan source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray(this Span source) - => - FlatArray.From(source); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/Extensions.ToFlatArray.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/Extensions.ToFlatArray.cs deleted file mode 100644 index 5c469f9..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/Extensions.ToFlatArray.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; - -namespace System.Linq; - -partial class FlatArrayExtensions -{ - public static FlatArray ToFlatArray([AllowNull] this T[] source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray(this FlatArray source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray(this FlatArray? source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray([AllowNull] this List source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray(this ImmutableArray source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray(this ImmutableArray? source) - => - FlatArray.From(source); - - public static FlatArray ToFlatArray([AllowNull] this IEnumerable source) - => - FlatArray.From(source); -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/FlatArrayExtensions.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/FlatArrayExtensions.cs deleted file mode 100644 index 41d6402..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayExtensions/FlatArrayExtensions.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace System.Linq; - -public static partial class FlatArrayExtensions -{ -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.InnerItemType.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.InnerItemType.cs deleted file mode 100644 index b5b2431..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.InnerItemType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace System.Collections.Generic; - -partial class FlatArrayJsonConverter -{ - private static class InnerItemType - { - internal static readonly Type Value = typeof(T); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.Read.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.Read.cs deleted file mode 100644 index 1220981..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.Read.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Diagnostics; -using System.Text.Json; - -namespace System.Collections.Generic; - -partial class FlatArrayJsonConverter -{ - public override FlatArray Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - Debug.Assert(options is not null); - - if (reader.TokenType is JsonTokenType.Null) - { - return default; - } - - if (reader.TokenType is not JsonTokenType.StartArray) - { - throw new JsonException("The last processed JSON token is not the start of an array."); - } - - var list = new List(); - - while (reader.Read()) - { - if (reader.TokenType is JsonTokenType.EndArray) - { - return FlatArray.From(list); - } - - var item = itemConverter.Read(ref reader, InnerItemType.Value, options); - list.Add(item!); - } - - throw new JsonException("Reading the JSON completed, but the end of the array was not found."); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.Write.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.Write.cs deleted file mode 100644 index 2fde7d4..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/Converter.Write.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Diagnostics; -using System.Text.Json; - -namespace System.Collections.Generic; - -partial class FlatArrayJsonConverter -{ - public override void Write(Utf8JsonWriter writer, FlatArray value, JsonSerializerOptions options) - { - Debug.Assert(writer is not null); - Debug.Assert(options is not null); - - writer.WriteStartArray(); - - value.InternalForEach(item => itemConverter.Write(writer, item, options)); - - writer.WriteEndArray(); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/FlatArrayJsonConverter.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/FlatArrayJsonConverter.cs deleted file mode 100644 index 868d2ff..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverter/FlatArrayJsonConverter.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Diagnostics; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace System.Collections.Generic; - -internal sealed partial class FlatArrayJsonConverter : JsonConverter> -{ - private readonly JsonConverter itemConverter; - - public FlatArrayJsonConverter(JsonSerializerOptions options) - { - Debug.Assert(options is not null); - - itemConverter = (JsonConverter)options.GetConverter(InnerItemType.Value); - - Debug.Assert(itemConverter is not null); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/Factory.CanConvert.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/Factory.CanConvert.cs deleted file mode 100644 index 7ea1f0e..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/Factory.CanConvert.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Diagnostics; - -namespace System.Collections.Generic; - -partial class FlatArrayJsonConverterFactory -{ - public override bool CanConvert(Type typeToConvert) - { - Debug.Assert(typeToConvert is not null); - - return - typeToConvert.IsGenericType && - typeToConvert.GetGenericTypeDefinition() == typeof(FlatArray<>); - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/Factory.CreateConverter.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/Factory.CreateConverter.cs deleted file mode 100644 index 077ad46..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/Factory.CreateConverter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Diagnostics; -using System.Reflection; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace System.Collections.Generic; - -partial class FlatArrayJsonConverterFactory -{ - public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options) - { - Debug.Assert(typeToConvert is not null); - Debug.Assert(options is not null); - - Debug.Assert(CanConvert(typeToConvert)); - - var itemType = typeToConvert.GetGenericArguments()[0]; - - var converter = (JsonConverter?)Activator.CreateInstance( - type: typeof(FlatArrayJsonConverter<>).MakeGenericType(itemType), - bindingAttr: BindingFlags.Instance | BindingFlags.Public, - binder: null, - args: new object?[] { options }, - culture: null); - - Debug.Assert(converter is not null); - - return converter; - } -} diff --git a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/FlatArrayJsonConverterFactory.cs b/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/FlatArrayJsonConverterFactory.cs deleted file mode 100644 index d2d195a..0000000 --- a/src/collections-flat-array/Collections.FlatArray/FlatArrayJsonConverterFactory/FlatArrayJsonConverterFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Text.Json.Serialization; - -namespace System.Collections.Generic; - -internal sealed partial class FlatArrayJsonConverterFactory : JsonConverterFactory -{ -} diff --git a/src/collections/Collections/Collections.csproj b/src/collections/Collections/Collections.csproj index dfe48b7..353d59f 100644 --- a/src/collections/Collections/Collections.csproj +++ b/src/collections/Collections/Collections.csproj @@ -33,7 +33,6 @@ -