Skip to content

Commit

Permalink
Reuse test constants
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Dec 7, 2024
1 parent 43ea19e commit 312c65e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/DotNext.Tests/Buffers/BufferWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public static void Rendering()
[InlineData(124)]
public static void WriteStringBuilder(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
var str = Random.Shared.NextString(Alphabet, stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
Expand All @@ -364,7 +364,7 @@ public static void WriteStringBuilder(int stringLength)
[InlineData(124)]
public static void WriteStringBuilder2(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
var str = Random.Shared.NextString(Alphabet, stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Tests/Buffers/ChunkSequenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void CopyFromSequence()
[InlineData(124)]
public static void StringBuilderToSequence(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
var str = Random.Shared.NextString(Alphabet, stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext.Tests/Buffers/SpanReaderWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public static void Rendering()
[InlineData(124)]
public static void WriteStringBuilder(int stringLength)
{
var str = Random.Shared.NextString("abcdefghijklmnopqrstuvwxyz", stringLength);
var str = Random.Shared.NextString(Alphabet, stringLength);

var builder = new StringBuilder();
for (var i = 0; i < 3; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ internal LocalMember(bool smallAmountOfMetadata = false)
metadata.Add("a", "b");
else
{
const string AllowedChars = "abcdefghijklmnopqrstuvwxyz1234567890";
const string allowedChars = Alphabet + Numbers;
for (var i = 0; i < 20; i++)
metadata.Add(string.Concat("key", i.ToString()), Random.Shared.NextString(AllowedChars, 20));
metadata.Add(string.Concat("key", i.ToString()), Random.Shared.NextString(allowedChars, 20));
}
Metadata = metadata.ToImmutableDictionary();
}
Expand Down
4 changes: 4 additions & 0 deletions src/DotNext.Tests/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace DotNext;
[ExcludeFromCodeCoverage]
public abstract class Test : Assert
{
protected const string Alphabet = "abcdefghijklmnopqrstuvwxyz";
protected const string AlphabetUpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXY";
protected const string Numbers = "0123456789";

private protected static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(20);

private protected static byte[] RandomBytes(int size)
Expand Down

0 comments on commit 312c65e

Please sign in to comment.