-
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.
Merge branch 'Cleaning-up-Primitives'
- Loading branch information
Showing
63 changed files
with
4,682 additions
and
3,112 deletions.
There are no files selected for viewing
Empty file.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,77 @@ | ||
namespace Dgmjr.Primitives.Tests; | ||
|
||
using Dgmjr.Primitives; | ||
|
||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
public class DurationTests : BaseTest | ||
{ | ||
public DurationTests(IOutputHelper output) | ||
: base(output) { } | ||
|
||
[Theory] | ||
[MemberData(nameof(DayTimeDurationTestData))] | ||
public void Day_Time_Duration_Parses_Correctly( | ||
string dayTimeDuration, | ||
duration expectedDuration | ||
) | ||
{ | ||
var dtd = DayTimeDuration.Parse(dayTimeDuration); | ||
((duration)dtd).Should().Be(expectedDuration); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(YearMonthDurationTestData))] | ||
public void Year_Month_Duration_Parses_Correctly( | ||
string yearMonthDuration, | ||
duration expectedDuration | ||
) | ||
{ | ||
var dtd = YearMonthDuration.Parse(yearMonthDuration); | ||
((duration)dtd).Should().Be(expectedDuration); | ||
} | ||
|
||
public static IEnumerable<object[]> DayTimeDurationTestData => | ||
new[] | ||
{ | ||
new object[] | ||
{ | ||
"-P12DT13H27M12S", | ||
duration.FromMilliseconds(new duration(12, 13, 27, 12).TotalMilliseconds * -1) | ||
}, | ||
new object[] { "-PT525600M", duration.FromMinutes(-525600) }, | ||
new object[] { "PT525600M", duration.FromMinutes(525600) } | ||
}; | ||
|
||
public static IEnumerable<object[]> YearMonthDurationTestData => | ||
new[] | ||
{ | ||
new object[] | ||
{ | ||
"-P6500Y1M", | ||
duration.FromDays( | ||
duration | ||
.FromDays( | ||
(6500 * YearMonthDuration.DaysPerYear) + YearMonthDuration.DaysPerMonth | ||
) | ||
.TotalDays * -1 | ||
) | ||
}, | ||
new object[] | ||
{ | ||
"P1Y3M", | ||
duration.FromDays( | ||
YearMonthDuration.DaysPerYear + (3 * YearMonthDuration.DaysPerMonth) | ||
) | ||
}, | ||
new object[] | ||
{ | ||
"-P1Y3M", | ||
duration.FromDays( | ||
-(YearMonthDuration.DaysPerYear + (3 * YearMonthDuration.DaysPerMonth)) | ||
) | ||
}, | ||
new object[] { "P3M", duration.FromDays(90) } | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,22 +1,21 @@ | ||
namespace Dgmjr.Primitives.Tests; | ||
|
||
using System.Net.Mail; | ||
|
||
public class EmailAddressTests : PrimitivesTests<EmailAddress, EmailAddressTests> | ||
{ | ||
public EmailAddressTests(ITestOutputHelper output) : base(output) { } | ||
public EmailAddressTests(ITestOutputHelper output) | ||
: base(output) { } | ||
|
||
protected override string[][] InvalidValuesStrings => new[] | ||
{ | ||
new[] { "not an email" }, | ||
new[] { "missing@" }, | ||
new[] { "@missing-domain" } | ||
}; | ||
protected override string[][] InvalidValuesStrings => | ||
new[] { new[] { "not an email" }, new[] { "missing@" }, new[] { "@missing-domain" } }; | ||
|
||
protected override string[][] ValidValuesStrings => new[] | ||
{ | ||
new[] { "[email protected]" }, | ||
new[] { "[email protected]" }, | ||
new[] { "[email protected]" }, | ||
new[] { "[email protected]" } | ||
}; | ||
protected override string[][] ValidValuesStrings => | ||
new[] | ||
{ | ||
new[] { "[email protected]" }, | ||
new[] { "[email protected]" }, | ||
new[] { "[email protected]" }, | ||
new[] { "[email protected]" } | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
namespace Dgmjr.Primitives.Tests; | ||
|
||
using static Microsoft.Extensions.Logging.LogLevel; | ||
|
||
public static partial class LoggerExtensions | ||
{ | ||
[LoggerMessage(Information, "{PrimitiveType} original value: \"{OriginalValue}\"")] | ||
public static partial void LogOriginalValue(this ILogger logger, Type primitiveType, string originalValue); | ||
public static partial void LogOriginalValue( | ||
this ILogger logger, | ||
Type primitiveType, | ||
string originalValue | ||
); | ||
} |
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
Oops, something went wrong.