-
Notifications
You must be signed in to change notification settings - Fork 46
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
042130b
commit d3a00a0
Showing
97 changed files
with
4,201 additions
and
4,070 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
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
28 changes: 28 additions & 0 deletions
28
...s/NodaMoney.Tests/CurrencyInfoBuilderSpec/GivenIWantToReplaceIsoCurrencyWithOwnVersion.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,28 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
using NodaMoney.Tests.Helpers; | ||
|
||
namespace NodaMoney.Tests.CurrencyInfoBuilderSpec; | ||
|
||
[Collection(nameof(NoParallelization))] | ||
public class GivenIWantToReplaceIsoCurrencyWithOwnVersion | ||
{ | ||
[Fact] | ||
public void WhenReplacingEuroWithCustom_ThenThisShouldSucceed() | ||
{ | ||
// Panamanian balboa | ||
CurrencyInfo oldEuro = CurrencyInfoBuilder.Unregister("PAB"); | ||
|
||
var builder = new CurrencyInfoBuilder("PAB"); | ||
builder.LoadDataFromCurrencyInfo(oldEuro); | ||
builder.EnglishName = "New Panamanian balboa"; | ||
builder.DecimalDigits = 1; | ||
|
||
builder.Register(); | ||
|
||
CurrencyInfo newEuro = CurrencyInfo.FromCode("PAB"); | ||
newEuro.Symbol.Should().Be("B/."); | ||
newEuro.EnglishName.Should().Be("New Panamanian balboa"); | ||
newEuro.DecimalDigits.Should().Be(1); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
tests/NodaMoney.Tests/CurrencyInfoBuilderSpec/GivenIWantToUnregisterCurrency.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,68 @@ | ||
using System; | ||
using FluentAssertions; | ||
using NodaMoney.Tests.Helpers; | ||
using Xunit; | ||
|
||
namespace NodaMoney.Tests.CurrencyInfoBuilderSpec; | ||
|
||
[Collection(nameof(NoParallelization))] | ||
public class GivenIWantToUnregisterCurrency | ||
{ | ||
[Fact] | ||
public void WhenUnregisterIsoCurrency_ThenThisMustSucceed() | ||
{ | ||
var money = Currency.FromCode("PEN"); // should work | ||
|
||
CurrencyInfoBuilder.Unregister("PEN"); | ||
Action action = () => Currency.FromCode("PEN"); | ||
|
||
action.Should().Throw<InvalidCurrencyException>().WithMessage("*unknown*currency*"); | ||
} | ||
|
||
[Fact] | ||
public void WhenUnregisterCustomCurrency_ThenThisMustSucceed() | ||
{ | ||
var builder = new CurrencyInfoBuilder("XYZ") | ||
{ | ||
EnglishName = "Xyz", | ||
Symbol = "฿", | ||
NumericCode = "123", // iso number | ||
DecimalDigits = 4, | ||
IsIso4217 = false | ||
}; | ||
|
||
builder.Register(); | ||
//Currency xyz = Currency.FromCode("XYZ", "virtual"); // should work | ||
Currency xyz = Currency.FromCode("XYZ"); // should work | ||
|
||
CurrencyInfoBuilder.Unregister("XYZ"); | ||
//Action action = () => Currency.FromCode("XYZ", "virtual"); | ||
Action action = () => Currency.FromCode("XYZ"); | ||
|
||
action.Should().Throw<InvalidCurrencyException>().WithMessage("*unknown*currency*"); | ||
} | ||
|
||
[Fact] | ||
public void WhenCurrencyDoesNotExist_ThenThrowException() | ||
{ | ||
Action action = () => CurrencyInfoBuilder.Unregister("ABC"); | ||
|
||
action.Should().Throw<InvalidCurrencyException>().WithMessage("*is unknown currency code!"); | ||
} | ||
|
||
[Fact] | ||
public void WhenCodeIsNull_ThenThrowException() | ||
{ | ||
Action action = () => CurrencyInfoBuilder.Unregister(null); | ||
|
||
action.Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void WhenCodeIsEmpty_ThenThrowException() | ||
{ | ||
Action action = () => CurrencyInfoBuilder.Unregister(""); | ||
|
||
action.Should().Throw<ArgumentNullException>(); | ||
} | ||
} |
Oops, something went wrong.