-
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.
- The default constructor, generated for record types when marked as partial, now applies the fully qualified type when propagating the default value, thereby removing the potential for ambiguity with the projection constructor (#8).
- Loading branch information
Showing
37 changed files
with
464 additions
and
52 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
40 changes: 40 additions & 0 deletions
40
src/Fluentify.Console.Tests/Class/SingleTests/WhenWithAgeIsCalled.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,40 @@ | ||
namespace Fluentify.Console.Class.SingleTests; | ||
|
||
public sealed class WhenWithAgeIsCalled | ||
{ | ||
[Fact] | ||
public void GivenNullSubjectThenArgumentNullExceptionIsThrown() | ||
{ | ||
// Arrange | ||
Single? subject = default; | ||
|
||
// Act | ||
Func<Single> act = () => subject!.WithAge(1); | ||
|
||
// Assert | ||
_ = act.Should().Throw<ArgumentNullException>() | ||
.WithParameterName(nameof(subject)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1)] | ||
[InlineData(-1)] | ||
[InlineData(0)] | ||
[InlineData(int.MinValue)] | ||
[InlineData(int.MaxValue)] | ||
public void GivenAnAgeThenTheValueIsApplied(int age) | ||
{ | ||
// Arrange | ||
var original = new Single | ||
{ | ||
Age = Random.Shared.Next(), | ||
}; | ||
|
||
// Act | ||
Single actual = original.WithAge(age); | ||
|
||
// Assert | ||
_ = actual.Should().NotBeSameAs(original); | ||
_ = actual.Age.Should().Be(age); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Fluentify.Console.Tests/Record/SingleTests/WhenWithAgeIsCalled.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,40 @@ | ||
namespace Fluentify.Console.Record.SingleTests; | ||
|
||
public sealed class WhenWithAgeIsCalled | ||
{ | ||
[Fact] | ||
public void GivenNullSubjectThenArgumentNullExceptionIsThrown() | ||
{ | ||
// Arrange | ||
Single? subject = default; | ||
|
||
// Act | ||
Func<Single> act = () => subject!.WithAge(1); | ||
|
||
// Assert | ||
_ = act.Should().Throw<ArgumentNullException>() | ||
.WithParameterName(nameof(subject)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1)] | ||
[InlineData(-1)] | ||
[InlineData(0)] | ||
[InlineData(int.MinValue)] | ||
[InlineData(int.MaxValue)] | ||
public void GivenAnAgeThenTheValueIsApplied(int age) | ||
{ | ||
// Arrange | ||
var original = new Single | ||
{ | ||
Age = Random.Shared.Next(), | ||
}; | ||
|
||
// Act | ||
Single actual = original.WithAge(age); | ||
|
||
// Assert | ||
_ = actual.Should().NotBeSameAs(original); | ||
_ = actual.Age.Should().Be(age); | ||
} | ||
} |
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
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
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
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
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
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
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
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
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,16 @@ | ||
namespace Fluentify.Console.Class; | ||
|
||
/// <summary> | ||
/// A class that demonstrates the libraries use on a type with just one property. | ||
/// </summary> | ||
[Fluentify] | ||
internal sealed class Single | ||
{ | ||
/// <summary> | ||
/// Gets the first property to be subject to the extension generator. | ||
/// </summary> | ||
/// <value> | ||
/// The first property to be subject to the extension generator. | ||
/// </value> | ||
public int Age { get; init; } | ||
} |
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
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,8 @@ | ||
namespace Fluentify.Console.Record; | ||
|
||
/// <summary> | ||
/// A record that demonstrates the libraries use on a type with just one property. | ||
/// </summary> | ||
/// <param name="Age">The first property to be subject to the extension generator.</param> | ||
[Fluentify] | ||
internal sealed partial record Single(int Age); |
Oops, something went wrong.