-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Snowflake.Data.Tests.Util | ||
{ | ||
internal static class TestData | ||
{ | ||
internal static string ByteArrayToHexString(byte[] ba) | ||
{ | ||
StringBuilder hex = new StringBuilder(ba.Length * 2); | ||
foreach (byte b in ba) | ||
hex.AppendFormat("{0:x2}", b); | ||
return hex.ToString(); | ||
} | ||
|
||
internal static T?[] NullEachNthValue<T>(T?[] sourceColumn, int nullEachNthItem) where T : struct | ||
{ | ||
var destination = new T?[sourceColumn.Length]; | ||
foreach (var rowIndex in Enumerable.Range(0, sourceColumn.Length)) | ||
destination[rowIndex] = rowIndex % nullEachNthItem == 0 ? null : sourceColumn[rowIndex]; | ||
return destination; | ||
} | ||
|
||
internal static T?[] NullEachNthValue<T>(T?[] sourceColumn, int nullEachNthItem) where T : class | ||
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Linux (net6.0, GCP)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Linux (net6.0, AZURE)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on MAC (net6.0, AWS)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net472, AZURE)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net472, AZURE)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net6.0, AZURE)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net6.0, AWS)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net471, AZURE)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net471, AZURE)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net472, GCP)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net472, GCP)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net6.0, GCP)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net471, AWS)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net471, AWS)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net471, GCP)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net471, GCP)
Check warning on line 24 in Snowflake.Data.Tests/Util/TestDataHelpers.cs GitHub Actions / Tests on Windows (net472, AWS)
|
||
{ | ||
var destination = new T?[sourceColumn.Length]; | ||
foreach (var rowIndex in Enumerable.Range(0, sourceColumn.Length)) | ||
destination[rowIndex] = rowIndex % nullEachNthItem == 0 ? null : sourceColumn[rowIndex]; | ||
return destination; | ||
} | ||
|
||
internal static object[] NullEachNthValueBesidesFirst(object[] sourceRow, int nullEachNthItem) | ||
{ | ||
var ret = new object[sourceRow.Length]; | ||
foreach (var column in Enumerable.Range(0, sourceRow.Length)) | ||
ret[column] = column > 0 && nullEachNthItem % (column + 1) == 0 ? null : sourceRow[column]; | ||
return ret; | ||
} | ||
|
||
internal static string RemoveBlanks(string text) | ||
=> text.Replace("\n", "").Replace(" ", ""); | ||
|
||
} | ||
} |