-
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.
- Loading branch information
1 parent
7ccb899
commit 9257d11
Showing
4 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Behavioral/DesignPatterns.Visitor.UnitTests/SizeVisitorTests.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,36 @@ | ||
using DesignPatterns.Visitor.Converters; | ||
using DesignPatterns.Visitor.Models; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace DesignPatterns.Visitor.UnitTests; | ||
|
||
public class SizeVisitorTests | ||
{ | ||
[Theory] | ||
[MemberData(nameof(TestCases))] | ||
public void GivenSize_WhenCallVisit_ThenResultAsExpected(ISize size, ISize expectedResult) | ||
{ | ||
var sizeVisitor = this.GetSut(); | ||
var actualResult = sizeVisitor.Visit(size); | ||
actualResult.ShouldBeEquivalentTo(expectedResult); | ||
} | ||
|
||
private IVisitor<ISize, ISize> GetSut() => new SizeVisitor( | ||
[ | ||
new KiloBytesToBytesConverter(), | ||
new MegaBytesToBytesConverter(), | ||
new GigaBytesToBytesConverter(), | ||
new TeraBytesToBytesConverter(), | ||
new PetaBytesToBytesConverter() | ||
]); | ||
|
||
public static IEnumerable<object[]> TestCases() | ||
{ | ||
yield return [new SizeInKiloBytes { Value = 100 }, new SizeInBytes { Value = 102400 }]; | ||
yield return [new SizeInMegaBytes { Value = 200 }, new SizeInBytes { Value = 209715200 }]; | ||
yield return [new SizeInGigaBytes { Value = 300 }, new SizeInBytes { Value = 322122547200 }]; | ||
yield return [new SizeInTeraBytes { Value = 400 }, new SizeInBytes { Value = 439804651110400 }]; | ||
yield return [new SizeInPetaBytes { Value = 500 }, new SizeInBytes { Value = 562949953421312000 }]; | ||
} | ||
} |
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