-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
347 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace MiniTwitch.Helix.Test.Converters; | ||
|
||
public class EnumConverterTest | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Text; | ||
using MiniTwitch.Helix.Internal.Json; | ||
|
||
namespace MiniTwitch.Helix.Test.Converters; | ||
|
||
public class IntConverterTest | ||
{ | ||
[Fact] | ||
public void Read_Int() | ||
{ | ||
var r = IntConverter.ReadInt(Encoding.UTF8.GetBytes("12345")); | ||
Assert.Equal(12345, r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Long() | ||
{ | ||
var r = IntConverter.ReadInt(Encoding.UTF8.GetBytes("8223372036854780000")); | ||
Assert.Equal(0, r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Empty() | ||
{ | ||
var r = IntConverter.ReadInt(Span<byte>.Empty); | ||
Assert.Equal(0, r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Null() | ||
{ | ||
var r2 = IntConverter.ReadInt(Encoding.UTF8.GetBytes("null")); | ||
Assert.Equal(0, r2); | ||
} | ||
|
||
[Fact] | ||
public void Read_Undefined() | ||
{ | ||
var r2 = IntConverter.ReadInt(Encoding.UTF8.GetBytes("forsen")); | ||
Assert.Equal(0, r2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Text; | ||
using MiniTwitch.Helix.Internal.Json; | ||
|
||
namespace MiniTwitch.Helix.Test.Converters; | ||
|
||
public class LongConverterTest | ||
{ | ||
[Fact] | ||
public void Read_Int() | ||
{ | ||
var r = LongConverter.ReadLong(Encoding.UTF8.GetBytes("12345")); | ||
Assert.Equal(12345, r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Long() | ||
{ | ||
var r = LongConverter.ReadLong(Encoding.UTF8.GetBytes("8223372036854780000")); | ||
Assert.Equal(8223372036854780000, r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Empty() | ||
{ | ||
var r = LongConverter.ReadLong(Span<byte>.Empty); | ||
Assert.Equal(0, r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Null() | ||
{ | ||
var r2 = LongConverter.ReadLong(Encoding.UTF8.GetBytes("null")); | ||
Assert.Equal(0, r2); | ||
} | ||
|
||
[Fact] | ||
public void Read_Undefined() | ||
{ | ||
var r2 = LongConverter.ReadLong(Encoding.UTF8.GetBytes("forsen")); | ||
Assert.Equal(0, r2); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
MiniTwitch.Helix.Test/Converters/OptionalLongConverterTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Text; | ||
using MiniTwitch.Helix.Internal.Json; | ||
|
||
namespace MiniTwitch.Helix.Test.Converters; | ||
|
||
public class OptionalLongConverterTest | ||
{ | ||
[Fact] | ||
public void Read_Int() | ||
{ | ||
var r = OptionalLongConverter.ReadLong(Encoding.UTF8.GetBytes("12345")); | ||
var val = Assert.NotNull(r); | ||
Assert.Equal(12345, val); | ||
} | ||
|
||
[Fact] | ||
public void Read_Long() | ||
{ | ||
var r = OptionalLongConverter.ReadLong(Encoding.UTF8.GetBytes("8223372036854780000")); | ||
var val = Assert.NotNull(r); | ||
Assert.Equal(8223372036854780000, val); | ||
} | ||
|
||
[Fact] | ||
public void Read_Empty() | ||
{ | ||
var r = OptionalLongConverter.ReadLong(Span<byte>.Empty); | ||
Assert.Null(r); | ||
} | ||
|
||
[Fact] | ||
public void Read_Null() | ||
{ | ||
var r2 = OptionalLongConverter.ReadLong(Encoding.UTF8.GetBytes("null")); | ||
Assert.Null(r2); | ||
} | ||
|
||
[Fact] | ||
public void Read_Undefined() | ||
{ | ||
var r2 = OptionalLongConverter.ReadLong(Encoding.UTF8.GetBytes("forsen")); | ||
Assert.Null(r2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.5.3" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MiniTwitch.Helix\MiniTwitch.Helix.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using MiniTwitch.Helix.Internal.Json; | ||
|
||
namespace MiniTwitch.Helix.Test; | ||
|
||
public class SnakeCaseTest | ||
{ | ||
[Fact] | ||
public void From_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertFromCase("hello_world"); | ||
Assert.Equal("HelloWorld", converted); | ||
} | ||
|
||
[Fact] | ||
public void From_Null_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertFromCase(null); | ||
Assert.Null(converted); | ||
} | ||
|
||
[Fact] | ||
public void From_Empty_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertFromCase(string.Empty); | ||
Assert.NotNull(converted); | ||
Assert.Empty(converted); | ||
} | ||
|
||
[Fact] | ||
public void From_Space_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertFromCase(" "); | ||
Assert.NotNull(converted); | ||
Assert.Equal(" ", converted); | ||
} | ||
|
||
[Fact] | ||
public void To_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertToCase("HelloForsenPajladaOne"); | ||
Assert.Equal("hello_forsen_pajlada_one", converted); | ||
} | ||
|
||
[Fact] | ||
public void Null_To_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertToCase(null); | ||
Assert.Null(converted); | ||
} | ||
|
||
[Fact] | ||
public void Empty_To_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertToCase(string.Empty); | ||
Assert.NotNull(converted); | ||
Assert.Empty(converted); | ||
} | ||
|
||
[Fact] | ||
public void Space_To_SnakeCase() | ||
{ | ||
ICaseConverter converter = SnakeCase.Instance; | ||
string? converted = converter.ConvertToCase(" "); | ||
Assert.NotNull(converted); | ||
Assert.Equal(" ", converted); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("MiniTwitch.Helix.Test")] |
Oops, something went wrong.