Skip to content

Commit

Permalink
Changed all constructors to private.
Browse files Browse the repository at this point in the history
Added additional unit test for operators.
  • Loading branch information
amsga committed Dec 30, 2024
1 parent 2fe6426 commit 320b754
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup .NET 8
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
Expand Down
2 changes: 1 addition & 1 deletion UUIDUtil/UUIDv1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class UUIDv1
protected internal static readonly Object s_initLock = new Object();
protected internal static readonly Object s_clockLock = new Object();

protected UUIDv1()
private UUIDv1()
{
}

Expand Down
2 changes: 1 addition & 1 deletion UUIDUtil/UUIDv3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace TensionDev.UUID
/// </summary>
public class UUIDv3

Check warning on line 26 in UUIDUtil/UUIDv3.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Rename class 'UUIDv3' to match pascal case naming rules, consider using 'UuiDv3'. (https://rules.sonarsource.com/csharp/RSPEC-101)
{
protected UUIDv3()
private UUIDv3()
{
}

Expand Down
2 changes: 1 addition & 1 deletion UUIDUtil/UUIDv4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace TensionDev.UUID
/// </summary>
public class UUIDv4

Check warning on line 24 in UUIDUtil/UUIDv4.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Rename class 'UUIDv4' to match pascal case naming rules, consider using 'UuiDv4'. (https://rules.sonarsource.com/csharp/RSPEC-101)
{
protected UUIDv4()
private UUIDv4()
{
}

Expand Down
2 changes: 1 addition & 1 deletion UUIDUtil/UUIDv5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace TensionDev.UUID
/// </summary>
public class UUIDv5

Check warning on line 26 in UUIDUtil/UUIDv5.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Rename class 'UUIDv5' to match pascal case naming rules, consider using 'UuiDv5'. (https://rules.sonarsource.com/csharp/RSPEC-101)
{
protected UUIDv5()
private UUIDv5()
{
}

Expand Down
2 changes: 1 addition & 1 deletion UUIDUtil/UUIDv6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UUIDv6
protected internal static readonly Object s_initLock = new Object();
protected internal static readonly Object s_clockLock = new Object();

protected UUIDv6()
private UUIDv6()
{
}

Expand Down
2 changes: 1 addition & 1 deletion UUIDUtil/UUIDv7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UUIDv7
protected internal static UInt16 s_counter = 0;

Check warning on line 29 in UUIDUtil/UUIDv7.cs

View workflow job for this annotation

GitHub Actions / .NET 8.0.x

Change the visibility of 's_counter' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
protected internal static readonly Object s_counterLock = new Object();

protected UUIDv7()
private UUIDv7()
{
}

Expand Down
202 changes: 202 additions & 0 deletions XUnitTestProjectUUID/UnitTestUuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,207 @@ public void TestToString7()

Assert.Throws<FormatException>(() => { uuid.ToString("C"); });
}

[Fact]
public void TestOperatorEquals1()
{
object other = new object();
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid == other;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorEquals2()
{
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid1 == uuid2;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorEquals3()
{
TensionDev.UUID.Uuid other = null;
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid == other;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorNotEquals1()
{
object other = new object();
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid != other;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorNotEquals2()
{
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid1 != uuid2;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorNotEquals3()
{
TensionDev.UUID.Uuid other = null;
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid != other;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorLessThan1()
{
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);

bool actualResult = uuid1 < uuid2;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorLessThan2()
{
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid1 < uuid2;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorLessThan3()
{
TensionDev.UUID.Uuid other = null;
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid < other;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorGreaterThan1()
{
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);

bool actualResult = uuid1 > uuid2;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorGreaterThan2()
{
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid1 > uuid2;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorGreaterThan3()
{
TensionDev.UUID.Uuid other = null;
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid > other;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorLessThanOrEqual1()
{
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);

bool actualResult = uuid1 <= uuid2;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorLessThanOrEqual2()
{
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid1 <= uuid2;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorLessThanOrEqual3()
{
TensionDev.UUID.Uuid other = null;
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid <= other;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorGreaterThanOrEqual1()
{
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);

bool actualResult = uuid1 >= uuid2;
Assert.False(actualResult);
}

[Fact]
public void TestOperatorGreaterThanOrEqual2()
{
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid1 >= uuid2;
Assert.True(actualResult);
}

[Fact]
public void TestOperatorGreaterThanOrEqual3()
{
TensionDev.UUID.Uuid other = null;
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);

bool actualResult = uuid >= other;
Assert.True(actualResult);
}
}
}

0 comments on commit 320b754

Please sign in to comment.