-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#28: Synergy.Contracts: Extracted dedicated test classes for DateTime…
… failures.
- Loading branch information
1 parent
382351f
commit f1a1423
Showing
4 changed files
with
93 additions
and
120 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
Contracts/Synergy.Contracts.Test/Failures/Dates/Fail.IfDateEmpty.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,45 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace Synergy.Contracts.Test.Failures.Dates; | ||
|
||
public class IfDateEmptyTest | ||
{ | ||
[Fact] | ||
public void IfDateEmptyWithName() | ||
{ | ||
// ARRANGE | ||
DateTime minDate = DateTime.MinValue; | ||
|
||
// ACT | ||
var exception = Assert.Throws<DesignByContractViolationException>( | ||
() => Fail.IfEmpty(minDate, nameof(minDate)) | ||
); | ||
|
||
// ASSERT | ||
Assert.Equal("'minDate' is empty = 01/01/0001 00:00:00", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void IfDateEmptyWithCallerArgumentExpression() | ||
{ | ||
// ARRANGE | ||
DateTime minDate = DateTime.MinValue; | ||
|
||
// ACT | ||
var exception = Assert.Throws<DesignByContractViolationException>( | ||
() => Fail.IfEmpty(minDate) | ||
); | ||
|
||
// ASSERT | ||
Assert.Equal("'minDate' is empty = 01/01/0001 00:00:00", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void IfDateEmptySuccess() | ||
{ | ||
// ACT | ||
Fail.IfEmpty(DateTime.Today, nameof(DateTime.Today)); | ||
Fail.IfEmpty(DateTime.Today); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Contracts/Synergy.Contracts.Test/Failures/Dates/var.FailIfEmpty.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,48 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace Synergy.Contracts.Test.Failures.Dates; | ||
|
||
public class FailIfEmptyTest | ||
{ | ||
[Fact] | ||
public void FailIfDateEmpty() | ||
{ | ||
// ARRANGE | ||
DateTime minDate = DateTime.MinValue; | ||
|
||
// ACT | ||
var exception = Assert.Throws<DesignByContractViolationException>( | ||
() => minDate.FailIfEmpty(nameof(minDate)) | ||
); | ||
|
||
// ASSERT | ||
Assert.Equal("'minDate' is empty = 01/01/0001 00:00:00", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void FailIfDateEmptyCallerArgumentExpression() | ||
{ | ||
// ARRANGE | ||
DateTime minDate = DateTime.MinValue; | ||
|
||
// ACT | ||
var exception = Assert.Throws<DesignByContractViolationException>( | ||
() => minDate.FailIfEmpty() | ||
); | ||
|
||
// ASSERT | ||
Assert.Equal("'minDate' is empty = 01/01/0001 00:00:00", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void FailIfDateEmptySuccess() | ||
{ | ||
// ACT | ||
// ReSharper disable once UnusedVariable | ||
var date1 = DateTime.Today.FailIfEmpty(nameof(DateTime.Today)); | ||
// ReSharper disable once UnusedVariable | ||
var date2 = DateTime.Today.FailIfEmpty(); | ||
} | ||
|
||
} |
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
118 changes: 0 additions & 118 deletions
118
Contracts/Synergy.Contracts.Test/Failures/FailDateTimeTest.cs
This file was deleted.
Oops, something went wrong.