Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 6.0.0 (#27)
Browse files Browse the repository at this point in the history
All new features excluding numerics and units
MrMatthewLayton authored Oct 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 556fd77 commit 2fb2690
Showing 230 changed files with 4,978 additions and 2,432 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@ root = true

[*]
max_line_length = 140
insert_final_newline = true
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2022 ONIXLabs
// Copyright 2020-2023 ONIXLabs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

namespace OnixLabs.Core.UnitTests.MockData;
namespace OnixLabs.Core.UnitTests.Data.Objects;

public sealed class Color : Enumeration<Color>
{
31 changes: 31 additions & 0 deletions OnixLabs.Core.UnitTests.Data/Objects/Element.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2020-2023 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.

namespace OnixLabs.Core.UnitTests.Data.Objects;

public sealed class Element
{
public Element(int hashCode = 0)
{
HashCode = hashCode;
}

public bool Called { get; set; }
private int HashCode { get; }

public override int GetHashCode()
{
return HashCode;
}
}
47 changes: 47 additions & 0 deletions OnixLabs.Core.UnitTests.Data/Objects/Numeric.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2020-2023 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 System.Numerics;

namespace OnixLabs.Core.UnitTests.Data.Objects;

public sealed class Numeric<T> : IEquatable<Numeric<T>> where T : INumber<T>
{
public Numeric(T value)
{
Value = value;
}

public T Value { get; }

public bool Equals(Numeric<T>? other)
{
return other is not null && other.Value == Value;
}

public override bool Equals(object? obj)
{
return obj is Numeric<T> other && Equals(other);
}

public override int GetHashCode()
{
return HashCode.Combine(Value);
}

public override string ToString()
{
return this.ToRecordString();
}
}
56 changes: 56 additions & 0 deletions OnixLabs.Core.UnitTests.Data/Objects/RecordLike.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2020-2023 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.

namespace OnixLabs.Core.UnitTests.Data.Objects;

public sealed class RecordLike : IEquatable<RecordLike>
{
public RecordLike(string text, int number, DateTime moment, Guid identifier)
{
Text = text;
Number = number;
Moment = moment;
Identifier = identifier;
}

public string Text { get; }
public int Number { get; }
public DateTime Moment { get; }
public Guid Identifier { get; }

public bool Equals(RecordLike? other)
{
return ReferenceEquals(this, other)
|| other is not null
&& other.Text == Text
&& other.Number == Number
&& other.Moment == Moment
&& other.Identifier == Identifier;
}

public override bool Equals(object? obj)
{
return Equals(obj as RecordLike);
}

public override int GetHashCode()
{
return HashCode.Combine(Text, Number, Moment, Identifier);
}

public override string ToString()
{
return $"RecordLike {{ Text = {Text}, Number = {Number}, Moment = {Moment}, Identifier = {Identifier} }}";
}
}
28 changes: 28 additions & 0 deletions OnixLabs.Core.UnitTests.Data/OnixLabs.Core.UnitTests.Data.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OnixLabs.Core\OnixLabs.Core.csproj" />
</ItemGroup>

</Project>
65 changes: 65 additions & 0 deletions OnixLabs.Core.UnitTests/ArrayExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2020-2023 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 Xunit;

namespace OnixLabs.Core.UnitTests;

public sealed class ArrayExtensionTests
{
[Fact(DisplayName = "Array.Copy should produce a copy of an array")]
public void CopyShouldProduceExpectedResult()
{
// Given
int[] array = { 1, 2, 3, 4, 5 };
int[] expected = { 1, 2, 3, 4, 5 };

// When
int[] actual = array.Copy();

// Then
Assert.Equal(expected, actual);
Assert.True(!ReferenceEquals(array, actual));
}

[Fact(DisplayName = "Array.Copy with index and count parameters should produce a copy of an array")]
public void CopyWithParametersShouldProduceExpectedResult()
{
// Given
int[] array = { 1, 2, 3, 4, 5 };
int[] expected = { 3, 4, 5 };

// When
int[] actual = array.Copy(2, 3);

// Then
Assert.Equal(expected, actual);
Assert.True(!ReferenceEquals(array, actual));
}

[Fact(DisplayName = "Array.ConcatenateWith should produce a concatenation of two arrays")]
public void ConcatenateWithShouldProduceExpectedResult()
{
// Given
int[] left = { 1, 2, 3, 4, 5 };
int[] right = { 6, 7, 8, 9, 10 };
int[] expected = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

// When
int[] actual = left.ConcatenateWith(right);

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

0 comments on commit 2fb2690

Please sign in to comment.