Skip to content

Commit 320b754

Browse files
committed
Changed all constructors to private.
Added additional unit test for operators.
1 parent 2fe6426 commit 320b754

File tree

8 files changed

+210
-8
lines changed

8 files changed

+210
-8
lines changed

.github/workflows/package-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
# Steps represent a sequence of tasks that will be executed as part of the job
2222
steps:
2323
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v4
2525

2626
- name: Setup .NET 8
27-
uses: actions/setup-dotnet@v1
27+
uses: actions/setup-dotnet@v3
2828
with:
2929
dotnet-version: 8.0.x
3030
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json

UUIDUtil/UUIDv1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class UUIDv1
3030
protected internal static readonly Object s_initLock = new Object();
3131
protected internal static readonly Object s_clockLock = new Object();
3232

33-
protected UUIDv1()
33+
private UUIDv1()
3434
{
3535
}
3636

UUIDUtil/UUIDv3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace TensionDev.UUID
2525
/// </summary>
2626
public class UUIDv3
2727
{
28-
protected UUIDv3()
28+
private UUIDv3()
2929
{
3030
}
3131

UUIDUtil/UUIDv4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace TensionDev.UUID
2323
/// </summary>
2424
public class UUIDv4
2525
{
26-
protected UUIDv4()
26+
private UUIDv4()
2727
{
2828
}
2929

UUIDUtil/UUIDv5.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace TensionDev.UUID
2525
/// </summary>
2626
public class UUIDv5
2727
{
28-
protected UUIDv5()
28+
private UUIDv5()
2929
{
3030
}
3131

UUIDUtil/UUIDv6.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class UUIDv6
2929
protected internal static readonly Object s_initLock = new Object();
3030
protected internal static readonly Object s_clockLock = new Object();
3131

32-
protected UUIDv6()
32+
private UUIDv6()
3333
{
3434
}
3535

UUIDUtil/UUIDv7.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class UUIDv7
2929
protected internal static UInt16 s_counter = 0;
3030
protected internal static readonly Object s_counterLock = new Object();
3131

32-
protected UUIDv7()
32+
private UUIDv7()
3333
{
3434
}
3535

XUnitTestProjectUUID/UnitTestUuid.cs

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,207 @@ public void TestToString7()
321321

322322
Assert.Throws<FormatException>(() => { uuid.ToString("C"); });
323323
}
324+
325+
[Fact]
326+
public void TestOperatorEquals1()
327+
{
328+
object other = new object();
329+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
330+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
331+
332+
bool actualResult = uuid == other;
333+
Assert.False(actualResult);
334+
}
335+
336+
[Fact]
337+
public void TestOperatorEquals2()
338+
{
339+
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
340+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
341+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);
342+
343+
bool actualResult = uuid1 == uuid2;
344+
Assert.True(actualResult);
345+
}
346+
347+
[Fact]
348+
public void TestOperatorEquals3()
349+
{
350+
TensionDev.UUID.Uuid other = null;
351+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
352+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
353+
354+
bool actualResult = uuid == other;
355+
Assert.False(actualResult);
356+
}
357+
358+
[Fact]
359+
public void TestOperatorNotEquals1()
360+
{
361+
object other = new object();
362+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
363+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
364+
365+
bool actualResult = uuid != other;
366+
Assert.True(actualResult);
367+
}
368+
369+
[Fact]
370+
public void TestOperatorNotEquals2()
371+
{
372+
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
373+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
374+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);
375+
376+
bool actualResult = uuid1 != uuid2;
377+
Assert.False(actualResult);
378+
}
379+
380+
[Fact]
381+
public void TestOperatorNotEquals3()
382+
{
383+
TensionDev.UUID.Uuid other = null;
384+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
385+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
386+
387+
bool actualResult = uuid != other;
388+
Assert.True(actualResult);
389+
}
390+
391+
[Fact]
392+
public void TestOperatorLessThan1()
393+
{
394+
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
395+
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
396+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
397+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);
398+
399+
bool actualResult = uuid1 < uuid2;
400+
Assert.True(actualResult);
401+
}
402+
403+
[Fact]
404+
public void TestOperatorLessThan2()
405+
{
406+
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
407+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
408+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);
409+
410+
bool actualResult = uuid1 < uuid2;
411+
Assert.False(actualResult);
412+
}
413+
414+
[Fact]
415+
public void TestOperatorLessThan3()
416+
{
417+
TensionDev.UUID.Uuid other = null;
418+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
419+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
420+
421+
bool actualResult = uuid < other;
422+
Assert.False(actualResult);
423+
}
424+
425+
[Fact]
426+
public void TestOperatorGreaterThan1()
427+
{
428+
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
429+
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
430+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
431+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);
432+
433+
bool actualResult = uuid1 > uuid2;
434+
Assert.False(actualResult);
435+
}
436+
437+
[Fact]
438+
public void TestOperatorGreaterThan2()
439+
{
440+
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
441+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
442+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);
443+
444+
bool actualResult = uuid1 > uuid2;
445+
Assert.False(actualResult);
446+
}
447+
448+
[Fact]
449+
public void TestOperatorGreaterThan3()
450+
{
451+
TensionDev.UUID.Uuid other = null;
452+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
453+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
454+
455+
bool actualResult = uuid > other;
456+
Assert.True(actualResult);
457+
}
458+
459+
[Fact]
460+
public void TestOperatorLessThanOrEqual1()
461+
{
462+
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
463+
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
464+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
465+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);
466+
467+
bool actualResult = uuid1 <= uuid2;
468+
Assert.True(actualResult);
469+
}
470+
471+
[Fact]
472+
public void TestOperatorLessThanOrEqual2()
473+
{
474+
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
475+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
476+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);
477+
478+
bool actualResult = uuid1 <= uuid2;
479+
Assert.True(actualResult);
480+
}
481+
482+
[Fact]
483+
public void TestOperatorLessThanOrEqual3()
484+
{
485+
TensionDev.UUID.Uuid other = null;
486+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
487+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
488+
489+
bool actualResult = uuid <= other;
490+
Assert.False(actualResult);
491+
}
492+
493+
[Fact]
494+
public void TestOperatorGreaterThanOrEqual1()
495+
{
496+
string vs1 = "7d444830-9dc0-11d1-b245-5ffdce74fad2";
497+
string vs2 = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
498+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs1);
499+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs2);
500+
501+
bool actualResult = uuid1 >= uuid2;
502+
Assert.False(actualResult);
503+
}
504+
505+
[Fact]
506+
public void TestOperatorGreaterThanOrEqual2()
507+
{
508+
string vs = "{7d444840-9dc0-11d1-b245-5ffdce74fad2}";
509+
TensionDev.UUID.Uuid uuid1 = TensionDev.UUID.Uuid.Parse(vs);
510+
TensionDev.UUID.Uuid uuid2 = TensionDev.UUID.Uuid.Parse(vs);
511+
512+
bool actualResult = uuid1 >= uuid2;
513+
Assert.True(actualResult);
514+
}
515+
516+
[Fact]
517+
public void TestOperatorGreaterThanOrEqual3()
518+
{
519+
TensionDev.UUID.Uuid other = null;
520+
string vs = "7d444840-9dc0-11d1-b245-5ffdce74fad2";
521+
TensionDev.UUID.Uuid uuid = TensionDev.UUID.Uuid.Parse(vs);
522+
523+
bool actualResult = uuid >= other;
524+
Assert.True(actualResult);
525+
}
324526
}
325527
}

0 commit comments

Comments
 (0)