Skip to content

Commit

Permalink
Working commit - Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMatthewLayton committed Sep 12, 2021
1 parent 9fe6d48 commit f5ddbb0
Show file tree
Hide file tree
Showing 146 changed files with 10,104 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: .NET

on:
push:
branches:
- 'main'
- 'release'
pull_request:
branches:
- '**'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

*.swp
*.*~
project.lock.json
.DS_Store
*.pyc

# User-specific files
*.rsuser
*.suo
Expand Down Expand Up @@ -348,3 +354,16 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Visual Studio Code
.vscode

# Jetbrains Rider
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/

#nuget
nuget.config
13 changes: 13 additions & 0 deletions .idea/.idea.onixlabs-dotnet/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.onixlabs-dotnet/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.onixlabs-dotnet/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.onixlabs-dotnet/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions OnixLabs.Core.UnitTests/Base16Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2020-2021 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using OnixLabs.Core.Text;
using Xunit;

namespace OnixLabs.Core.UnitTests
{
public sealed class Base16Tests
{
[Theory(DisplayName = "Base16_FromString should produce the expected Base-16 value.")]
[InlineData("31323334353637383930", "1234567890")]
[InlineData("4142434445464748494a4b4c4d4e4f505152535455565758595a", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("6162636465666768696a6b6c6d6e6f707172737475767778797a", "abcdefghijklmnopqrstuvwxyz")]
public void Base16FromStringShouldProduceTheExpectedBase16Value(string expected, string value)
{
// Arrange
Base16 candidate = Base16.FromString(value);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base16_Parse should produce the expected plain text value.")]
[InlineData("1234567890", "31323334353637383930")]
[InlineData("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "4142434445464748494a4b4c4d4e4f505152535455565758595a")]
[InlineData("abcdefghijklmnopqrstuvwxyz", "6162636465666768696a6b6c6d6e6f707172737475767778797a")]
public void Base16ParseShouldProduceTheExpectedPlainTextValue(string expected, string value)
{
// Arrange
Base16 candidate = Base16.Parse(value);

// Act
string actual = candidate.ToPlainTextString();

// Assert
Assert.Equal(expected, actual);
}
}
}
70 changes: 70 additions & 0 deletions OnixLabs.Core.UnitTests/Base32Base32HexAlphabetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2020-2021 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using OnixLabs.Core.Text;
using Xunit;

namespace OnixLabs.Core.UnitTests
{
public sealed class Base32Base32HexAlphabetTests
{
[Theory(DisplayName = "Base32_FromString without padding should produce the expected Base-32 value.")]
[InlineData("64P36D1L6ORJGE9G", "1234567890")]
[InlineData("85146H258P3KGIAA9D64QJIFA18L4KQKALB5EM2PB8======", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("C5H66P35CPJMGQBADDM6QRJFE1ON4SRKELR7EU3PF8======", "abcdefghijklmnopqrstuvwxyz")]
public void Base32FromStringWithPaddingShouldProduceTheExpectedBase32Value(string expected, string value)
{
// Arrange
Base32 candidate = Base32.FromString(value, Base32Alphabet.Base32Hex, true);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base32_FromString without padding should produce the expected Base-32 value.")]
[InlineData("64P36D1L6ORJGE9G", "1234567890")]
[InlineData("85146H258P3KGIAA9D64QJIFA18L4KQKALB5EM2PB8", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("C5H66P35CPJMGQBADDM6QRJFE1ON4SRKELR7EU3PF8", "abcdefghijklmnopqrstuvwxyz")]
public void Base32FromStringWithoutPaddingShouldProduceTheExpectedBase32Value(string expected, string value)
{
// Arrange
Base32 candidate = Base32.FromString(value, Base32Alphabet.Base32Hex, false);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base32_Parse should produce the expected plain text value.")]
[InlineData("1234567890", "64P36D1L6ORJGE9G")]
[InlineData("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "85146H258P3KGIAA9D64QJIFA18L4KQKALB5EM2PB8")]
[InlineData("abcdefghijklmnopqrstuvwxyz", "C5H66P35CPJMGQBADDM6QRJFE1ON4SRKELR7EU3PF8")]
public void Base32ParseShouldProduceTheExpectedPlainTextValue(string expected, string value)
{
// Arrange
Base32 candidate = Base32.Parse(value, Base32Alphabet.Base32Hex);

// Act
string actual = candidate.ToPlainTextString();

// Assert
Assert.Equal(expected, actual);
}
}
}
70 changes: 70 additions & 0 deletions OnixLabs.Core.UnitTests/Base32CrockfordAlphabetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2020-2021 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using OnixLabs.Core.Text;
using Xunit;

namespace OnixLabs.Core.UnitTests
{
public sealed class Base32CrockfordAlphabetTests
{
[Theory(DisplayName = "Base32_FromString without padding should produce the expected Base-32 value.")]
[InlineData("64S36D1N6RVKGE9G", "1234567890")]
[InlineData("85146H258S3MGJAA9D64TKJFA18N4MTMANB5EP2SB8======", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("C5H66S35CSKPGTBADDP6TVKFE1RQ4WVMENV7EY3SF8======", "abcdefghijklmnopqrstuvwxyz")]
public void Base32FromStringWithPaddingShouldProduceTheExpectedBase32Value(string expected, string value)
{
// Arrange
Base32 candidate = Base32.FromString(value, Base32Alphabet.Crockford, true);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base32_FromString without padding should produce the expected Base-32 value.")]
[InlineData("64S36D1N6RVKGE9G", "1234567890")]
[InlineData("85146H258S3MGJAA9D64TKJFA18N4MTMANB5EP2SB8", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("C5H66S35CSKPGTBADDP6TVKFE1RQ4WVMENV7EY3SF8", "abcdefghijklmnopqrstuvwxyz")]
public void Base32FromStringWithoutPaddingShouldProduceTheExpectedBase32Value(string expected, string value)
{
// Arrange
Base32 candidate = Base32.FromString(value, Base32Alphabet.Crockford, false);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base32_Parse should produce the expected plain text value.")]
[InlineData("1234567890", "64S36D1N6RVKGE9G")]
[InlineData("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "85146H258S3MGJAA9D64TKJFA18N4MTMANB5EP2SB8")]
[InlineData("abcdefghijklmnopqrstuvwxyz", "C5H66S35CSKPGTBADDP6TVKFE1RQ4WVMENV7EY3SF8")]
public void Base32ParseShouldProduceTheExpectedPlainTextValue(string expected, string value)
{
// Arrange
Base32 candidate = Base32.Parse(value, Base32Alphabet.Crockford);

// Act
string actual = candidate.ToPlainTextString();

// Assert
Assert.Equal(expected, actual);
}
}
}
70 changes: 70 additions & 0 deletions OnixLabs.Core.UnitTests/Base32DefaultAlphabetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2020-2021 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using OnixLabs.Core.Text;
using Xunit;

namespace OnixLabs.Core.UnitTests
{
public sealed class Base32DefaultAlphabetTests
{
[Theory(DisplayName = "Base32_FromString without padding should produce the expected Base-32 value.")]
[InlineData("GEZDGNBVGY3TQOJQ", "1234567890")]
[InlineData("IFBEGRCFIZDUQSKKJNGE2TSPKBIVEU2UKVLFOWCZLI======", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("MFRGGZDFMZTWQ2LKNNWG23TPOBYXE43UOV3HO6DZPI======", "abcdefghijklmnopqrstuvwxyz")]
public void Base32FromStringWithPaddingShouldProduceTheExpectedBase32Value(string expected, string value)
{
// Arrange
Base32 candidate = Base32.FromString(value, Base32Alphabet.Default, true);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base32_FromString without padding should produce the expected Base-32 value.")]
[InlineData("GEZDGNBVGY3TQOJQ", "1234567890")]
[InlineData("IFBEGRCFIZDUQSKKJNGE2TSPKBIVEU2UKVLFOWCZLI", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("MFRGGZDFMZTWQ2LKNNWG23TPOBYXE43UOV3HO6DZPI", "abcdefghijklmnopqrstuvwxyz")]
public void Base32FromStringWithoutPaddingShouldProduceTheExpectedBase32Value(string expected, string value)
{
// Arrange
Base32 candidate = Base32.FromString(value, Base32Alphabet.Default, false);

// Act
string actual = candidate.ToString();

// Assert
Assert.Equal(expected, actual);
}

[Theory(DisplayName = "Base32_Parse should produce the expected plain text value.")]
[InlineData("1234567890", "GEZDGNBVGY3TQOJQ")]
[InlineData("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "IFBEGRCFIZDUQSKKJNGE2TSPKBIVEU2UKVLFOWCZLI")]
[InlineData("abcdefghijklmnopqrstuvwxyz", "MFRGGZDFMZTWQ2LKNNWG23TPOBYXE43UOV3HO6DZPI")]
public void Base32ParseShouldProduceTheExpectedPlainTextValue(string expected, string value)
{
// Arrange
Base32 candidate = Base32.Parse(value, Base32Alphabet.Default);

// Act
string actual = candidate.ToPlainTextString();

// Assert
Assert.Equal(expected, actual);
}
}
}
Loading

0 comments on commit f5ddbb0

Please sign in to comment.