-
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
66d5848
commit c9c1c2d
Showing
5 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Behavioral/DesignPatterns.Visitor.UnitTests/Converters/GigaBytesToBytesConverterTests.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,53 @@ | ||
using DesignPatterns.Visitor.Converters; | ||
using DesignPatterns.Visitor.Models; | ||
using FluentAssertions.Execution; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace DesignPatterns.Visitor.UnitTests.Converters; | ||
|
||
public class GigaBytesToBytesConverterTests | ||
{ | ||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenConvertedSizeReturned() | ||
{ | ||
var expectedResult = new SizeInBytes { Value = 1024L * 1024 * 1024 }; | ||
var size = new SizeInGigaBytes { Value = 1L }; | ||
var sut = new GigaBytesToBytesConverter(); | ||
ISize? actualResult = null; | ||
var action = () => actualResult = sut.Convert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult.ShouldBeEquivalentTo(expectedResult); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenInvalidOperationExceptionThrown() | ||
{ | ||
var sut = new GigaBytesToBytesConverter(); | ||
var action = () => sut.Convert(null!); | ||
action | ||
.ShouldThrow<InvalidOperationException>() | ||
.Message.ShouldBe("Could not convert GigaBytes to Bytes."); | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallCanConvert_ThenTrueReturned() | ||
{ | ||
var size = new SizeInGigaBytes { Value = 1 }; | ||
var sut = new GigaBytesToBytesConverter(); | ||
bool? actualResult = null; | ||
var action = () => actualResult = sut.CanConvert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult?.ShouldBeTrue(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Behavioral/DesignPatterns.Visitor.UnitTests/Converters/KiloBytesToBytesConverterTests.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,53 @@ | ||
using DesignPatterns.Visitor.Converters; | ||
using DesignPatterns.Visitor.Models; | ||
using FluentAssertions.Execution; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace DesignPatterns.Visitor.UnitTests.Converters; | ||
|
||
public class KiloBytesToBytesConverterTests | ||
{ | ||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenConvertedSizeReturned() | ||
{ | ||
var expectedResult = new SizeInBytes { Value = 1024L }; | ||
var size = new SizeInKiloBytes { Value = 1L }; | ||
var sut = new KiloBytesToBytesConverter(); | ||
ISize? actualResult = null; | ||
var action = () => actualResult = sut.Convert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult.ShouldBeEquivalentTo(expectedResult); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenInvalidOperationExceptionThrown() | ||
{ | ||
var sut = new KiloBytesToBytesConverter(); | ||
var action = () => sut.Convert(null!); | ||
action | ||
.ShouldThrow<InvalidOperationException>() | ||
.Message.ShouldBe("Could not convert KiloBytes to Bytes."); | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallCanConvert_ThenTrueReturned() | ||
{ | ||
var size = new SizeInKiloBytes { Value = 1 }; | ||
var sut = new KiloBytesToBytesConverter(); | ||
bool? actualResult = null; | ||
var action = () => actualResult = sut.CanConvert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult?.ShouldBeTrue(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Behavioral/DesignPatterns.Visitor.UnitTests/Converters/MegaBytesToBytesConverterTests.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,53 @@ | ||
using DesignPatterns.Visitor.Converters; | ||
using DesignPatterns.Visitor.Models; | ||
using FluentAssertions.Execution; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace DesignPatterns.Visitor.UnitTests.Converters; | ||
|
||
public class MegaBytesToBytesConverterTests | ||
{ | ||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenConvertedSizeReturned() | ||
{ | ||
var expectedResult = new SizeInBytes { Value = 1024L * 1024 }; | ||
var size = new SizeInMegaBytes { Value = 1L }; | ||
var sut = new MegaBytesToBytesConverter(); | ||
ISize? actualResult = null; | ||
var action = () => actualResult = sut.Convert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult.ShouldBeEquivalentTo(expectedResult); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenInvalidOperationExceptionThrown() | ||
{ | ||
var sut = new MegaBytesToBytesConverter(); | ||
var action = () => sut.Convert(null!); | ||
action | ||
.ShouldThrow<InvalidOperationException>() | ||
.Message.ShouldBe("Could not convert MegaBytes to Bytes."); | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallCanConvert_ThenTrueReturned() | ||
{ | ||
var size = new SizeInMegaBytes { Value = 1 }; | ||
var sut = new MegaBytesToBytesConverter(); | ||
bool? actualResult = null; | ||
var action = () => actualResult = sut.CanConvert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult?.ShouldBeTrue(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Behavioral/DesignPatterns.Visitor.UnitTests/Converters/PetaBytesToBytesConverterTests.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,53 @@ | ||
using DesignPatterns.Visitor.Converters; | ||
using DesignPatterns.Visitor.Models; | ||
using FluentAssertions.Execution; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace DesignPatterns.Visitor.UnitTests.Converters; | ||
|
||
public class PetaBytesToBytesConverterTests | ||
{ | ||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenConvertedSizeReturned() | ||
{ | ||
var expectedResult = new SizeInBytes { Value = 1024L * 1024 * 1024 * 1024 * 1024 }; | ||
var size = new SizeInPetaBytes { Value = 1L }; | ||
var sut = new PetaBytesToBytesConverter(); | ||
ISize? actualResult = null; | ||
var action = () => actualResult = sut.Convert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult.ShouldBeEquivalentTo(expectedResult); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenInvalidOperationExceptionThrown() | ||
{ | ||
var sut = new PetaBytesToBytesConverter(); | ||
var action = () => sut.Convert(null!); | ||
action | ||
.ShouldThrow<InvalidOperationException>() | ||
.Message.ShouldBe("Could not convert PetaBytes to Bytes."); | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallCanConvert_ThenTrueReturned() | ||
{ | ||
var size = new SizeInPetaBytes { Value = 1 }; | ||
var sut = new PetaBytesToBytesConverter(); | ||
bool? actualResult = null; | ||
var action = () => actualResult = sut.CanConvert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult?.ShouldBeTrue(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Behavioral/DesignPatterns.Visitor.UnitTests/Converters/TeraBytesToBytesConverterTests.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,53 @@ | ||
using DesignPatterns.Visitor.Converters; | ||
using DesignPatterns.Visitor.Models; | ||
using FluentAssertions.Execution; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace DesignPatterns.Visitor.UnitTests.Converters; | ||
|
||
public class TeraBytesToBytesConverterTests | ||
{ | ||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenConvertedSizeReturned() | ||
{ | ||
var expectedResult = new SizeInBytes { Value = 1024L * 1024 * 1024 * 1024 }; | ||
var size = new SizeInTeraBytes { Value = 1L }; | ||
var sut = new TeraBytesToBytesConverter(); | ||
ISize? actualResult = null; | ||
var action = () => actualResult = sut.Convert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult.ShouldBeEquivalentTo(expectedResult); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallConvert_ThenInvalidOperationExceptionThrown() | ||
{ | ||
var sut = new TeraBytesToBytesConverter(); | ||
var action = () => sut.Convert(null!); | ||
action | ||
.ShouldThrow<InvalidOperationException>() | ||
.Message.ShouldBe("Could not convert TeraBytes to Bytes."); | ||
} | ||
|
||
[Fact] | ||
public void GivenSize_WhenCallCanConvert_ThenTrueReturned() | ||
{ | ||
var size = new SizeInTeraBytes { Value = 1 }; | ||
var sut = new TeraBytesToBytesConverter(); | ||
bool? actualResult = null; | ||
var action = () => actualResult = sut.CanConvert(size); | ||
|
||
using (new AssertionScope()) | ||
{ | ||
action.ShouldNotThrow(); | ||
actualResult.ShouldNotBeNull(); | ||
actualResult?.ShouldBeTrue(); | ||
} | ||
} | ||
} |