-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test console to unit test the behavior of the code generated by…
… the generator Fixed a bug where sequences where incorrectly compared
- Loading branch information
Showing
39 changed files
with
1,542 additions
and
41 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
158 changes: 158 additions & 0 deletions
158
src/Valuify.Console.Tests/NestingTests/WhenEqualityIsChecked.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,158 @@ | ||
namespace Valuify.Console.NestingTests; | ||
|
||
public abstract class WhenEqualityIsChecked | ||
{ | ||
[Fact] | ||
public void GivenIdenticalInstancesThenTheyAreDeemedEqual() | ||
{ | ||
// Arrange | ||
var instance1 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex", | ||
}; | ||
|
||
var instance2 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex", | ||
}; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance1, instance2); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void GivenADifferentNameThenTheyAreNotDeemedEqual() | ||
{ | ||
// Arrange | ||
var instance1 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple1", | ||
Qualification = "Complex", | ||
}; | ||
|
||
var instance2 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple2", | ||
Qualification = "Complex", | ||
}; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance1, instance2); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void GivenADifferentQualificationThenTheyAreNotDeemedEqual() | ||
{ | ||
// Arrange | ||
var instance1 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex1", | ||
}; | ||
|
||
var instance2 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex2", | ||
}; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance1, instance2); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void GivenDifferentTypeThenTheyAreDeemedNotEqual() | ||
{ | ||
// Arrange | ||
var instance1 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex", | ||
}; | ||
|
||
var instance2 = new Nesting | ||
{ | ||
Declaration = "struct", | ||
Name = "Simple", | ||
Qualification = "Complex", | ||
}; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance1, instance2); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void GivenOneInstanceIsNullThenTheyAreDeemedNotEqual() | ||
{ | ||
// Arrange | ||
var instance = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex", | ||
}; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance, default); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void GivenBothInstancesAreNullThenTheyAreDeemedEqual() | ||
{ | ||
// Arrange | ||
Nesting? instance1 = default; | ||
Nesting? instance2 = default; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance1, instance2); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void GivenSameReferenceThenTheyAreDeemedEqual() | ||
{ | ||
// Arrange | ||
var instance1 = new Nesting | ||
{ | ||
Declaration = "partial class", | ||
Name = "Simple", | ||
Qualification = "Complex", | ||
}; | ||
|
||
Nesting instance2 = instance1; | ||
|
||
// Act | ||
bool areEqual = AreEqual(instance1, instance2); | ||
|
||
// Assert | ||
_ = areEqual.Should().BeTrue(); | ||
} | ||
|
||
private protected abstract bool AreEqual(Nesting? instance1, Nesting? instance2); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Valuify.Console.Tests/NestingTests/WhenEqualityIsCheckedByEquals.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,17 @@ | ||
namespace Valuify.Console.NestingTests; | ||
|
||
using Valuify.Console; | ||
|
||
public sealed class WhenEqualityIsCheckedByEquals | ||
: WhenEqualityIsChecked | ||
{ | ||
private protected override bool AreEqual(Nesting? instance1, Nesting? instance2) | ||
{ | ||
if (instance1 is not null) | ||
{ | ||
return instance1.Equals((object?)instance2); | ||
} | ||
|
||
return true; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Valuify.Console.Tests/NestingTests/WhenEqualityIsCheckedByEquatable.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,17 @@ | ||
namespace Valuify.Console.NestingTests; | ||
|
||
using Valuify.Console; | ||
|
||
public sealed class WhenEqualityIsCheckedByEquatable | ||
: WhenEqualityIsChecked | ||
{ | ||
private protected override bool AreEqual(Nesting? instance1, Nesting? instance2) | ||
{ | ||
if (instance1 is not null) | ||
{ | ||
return instance1.Equals(instance2); | ||
} | ||
|
||
return true; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Valuify.Console.Tests/NestingTests/WhenEqualityIsCheckedByOperator.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,12 @@ | ||
namespace Valuify.Console.NestingTests; | ||
|
||
using Valuify.Console; | ||
|
||
public sealed class WhenEqualityIsCheckedByOperator | ||
: WhenEqualityIsChecked | ||
{ | ||
private protected override bool AreEqual(Nesting? instance1, Nesting? instance2) | ||
{ | ||
return instance1 == instance2; | ||
} | ||
} |
Oops, something went wrong.