From dbc80c1a7702c42e02c883ce00725adf765296f7 Mon Sep 17 00:00:00 2001 From: remyvd Date: Thu, 28 May 2015 22:32:17 +0200 Subject: [PATCH 01/19] Add TryParse tests --- NodaMoney.UnitTests/MoneyParsableTests.cs | 273 ++++++++++++++++++---- NodaMoney/Money.cs | 14 +- 2 files changed, 244 insertions(+), 43 deletions(-) diff --git a/NodaMoney.UnitTests/MoneyParsableTests.cs b/NodaMoney.UnitTests/MoneyParsableTests.cs index 861ae0d..e5c88c6 100644 --- a/NodaMoney.UnitTests/MoneyParsableTests.cs +++ b/NodaMoney.UnitTests/MoneyParsableTests.cs @@ -9,15 +9,48 @@ namespace NodaMoney.UnitTests static internal class MoneyParsableTests { [TestClass] - public class GivenIWantToParseImplicitCurrencySymbolUsedInMultipleCurrencies + public class GivenIWantToParseImplicitCurrency { + [TestMethod] + public void WhenInBelgiumDutchSpeaking_ThenThisShouldSucceed() + { + using (new SwitchCulture("nl-BE")) + { + var euro = Money.Parse(" 765,43"); + + euro.Should().Be(new Money(765.43m, "EUR")); + } + } + + [TestMethod] + public void WhenInBelgiumFrenchSpeaking_ThenThisShouldSucceed() + { + using (new SwitchCulture("fr-BE")) + { + var euro = Money.Parse("765,43 "); + + euro.Should().Be(new Money(765.43, "EUR")); + } + } + + [TestMethod] + public void WhenParsingNumberWithoutCurrency_ThenThisUseCurrencyOfCurrentCulture() + { + using (new SwitchCulture("nl-NL")) + { + var euro = Money.Parse("765,43"); + + euro.Should().Be(new Money(765.43, "EUR")); + } + } + [TestMethod] public void WhenParsingYenYuanSymbolInJapan_ThenThisShouldReturnJapaneseYen() { using (new SwitchCulture("ja-JP")) { var yen = Money.Parse(" 765"); - + yen.Should().Be(new Money(765m, "JPY")); } } @@ -80,43 +113,6 @@ public void WhenParsingDollarSymbolInNetherlands_ThenThisShouldFail() } } - [TestClass] - public class GivenIWantToParseImplicitCurrency - { - [TestMethod] - public void WhenInBelgiumDutchSpeaking_ThenThisShouldSucceed() - { - using (new SwitchCulture("nl-BE")) - { - var euro = Money.Parse(" 765,43"); - - euro.Should().Be(new Money(765.43m, "EUR")); - } - } - - [TestMethod] - public void WhenInBelgiumFrenchSpeaking_ThenThisShouldSucceed() - { - using (new SwitchCulture("fr-BE")) - { - var euro = Money.Parse("765,43 "); - - euro.Should().Be(new Money(765.43, "EUR")); - } - } - - [TestMethod] - public void WhenParsingNumberWithoutCurrency_ThenThisUseCurrencyOfCurrentCulture() - { - using (new SwitchCulture("nl-NL")) - { - var euro = Money.Parse("765,43"); - - euro.Should().Be(new Money(765.43, "EUR")); - } - } - } - [TestClass] public class GivenIWantToParseExplicitCurrency { @@ -311,5 +307,204 @@ public void WhenParsingJapaneseYen_ThenThisShouldBeRoundedUp() } } } + + [TestClass] + public class GivenIWantToTryParseImplicitCurrency + { + [TestMethod] + public void WhenInBelgiumDutchSpeaking_ThenThisShouldSucceed() + { + using (new SwitchCulture("nl-BE")) + { + Money euro; + Money.TryParse(" 765,43", out euro).Should().BeTrue(); + euro.Should().Be(new Money(765.43m, "EUR")); + } + } + + [TestMethod] + public void WhenInBelgiumFrenchSpeaking_ThenThisShouldSucceed() + { + using (new SwitchCulture("fr-BE")) + { + Money euro; + Money.TryParse("765,43 ", out euro).Should().BeTrue(); + euro.Should().Be(new Money(765.43, "EUR")); + } + } + + [TestMethod] + public void WhenParsingNumberWithoutCurrency_ThenThisUseCurrencyOfCurrentCulture() + { + using (new SwitchCulture("nl-NL")) + { + Money euro; + Money.TryParse("765,43", out euro).Should().BeTrue(); + euro.Should().Be(new Money(765.43, "EUR")); + } + } + + [TestMethod] + public void WhenParsingYenYuanSymbolInJapan_ThenThisShouldReturnJapaneseYen() + { + using (new SwitchCulture("ja-JP")) + { + Money yen; + Money.TryParse(" 765", out yen).Should().BeTrue(); + yen.Should().Be(new Money(765m, "JPY")); + } + } + + [TestMethod] + public void WhenParsingYenYuanSymbolInChina_ThenThisShouldReturnChineseYuan() + { + using (new SwitchCulture("zh-CN")) + { + Money yuan; + Money.TryParse(" 765", out yuan).Should().BeTrue(); + yuan.Should().Be(new Money(765m, "CNY")); + } + } + + [TestMethod] + public void WhenParsingYenYuanInNetherlands_ThenThisShouldReturnFalse() + { + // symbol is used for Japanese yen and Chinese yuan + using (new SwitchCulture("nl-NL")) + { + Money money; + Money.TryParse(" 765", out money).Should().BeFalse(); + money.Should().Be(new Money(0m, Currency.FromCode("XXX"))); + } + } + + [TestMethod] + public void WhenParsingDollarSymbolInUSA_ThenThisShouldReturnUSDollar() + { + using (new SwitchCulture("en-US")) + { + Money dollar; + Money.TryParse("$765.43", out dollar).Should().BeTrue(); + dollar.Should().Be(new Money(765.43m, "USD")); + } + } + + [TestMethod] + public void WhenParsingDollarSymbolInArgentina_ThenThisShouldReturnArgentinePeso() + { + using (new SwitchCulture("es-AR")) + { + Money peso; + Money.TryParse("$765,43", out peso).Should().BeTrue(); + peso.Should().Be(new Money(765.43m, "ARS")); + } + } + + [TestMethod] + public void WhenParsingDollarSymbolInNetherlands_ThenThisShouldReturnFalse() + { + // $ symbol is used for multiple currencies + using (new SwitchCulture("nl-NL")) + { + Money money; + Money.TryParse("$ 765,43", out money).Should().BeFalse(); + money.Should().Be(new Money(0m, Currency.FromCode("XXX"))); + } + } + } + + [TestClass] + public class GivenIWantToTryParseExplicitCurrency + { + [TestMethod] + public void WhenParsingYenInNetherlands_ThenThisShouldSucceed() + { + using (new SwitchCulture("nl-NL")) + { + Money yen; + Money.TryParse(" 765", Currency.FromCode("JPY"), out yen).Should().BeTrue(); + yen.Should().Be(new Money(765, "JPY")); + } + } + + [TestMethod] + public void WhenParsingArgentinePesoInUSA_ThenThisShouldReturnArgentinePeso() + { + using (new SwitchCulture("en-US")) + { + Money peso; + Money.TryParse("$765.43", Currency.FromCode("ARS"), out peso).Should().BeTrue(); + peso.Should().Be(new Money(765.43m, "ARS")); + } + } + + [TestMethod] + public void WhenParsingUSDollarSymbolInArgentina_ThenThisShouldReturnUSDollar() + { + using (new SwitchCulture("es-AR")) + { + Money dollar; + Money.TryParse("$765,43", Currency.FromCode("USD"), out dollar).Should().BeTrue(); + dollar.Should().Be(new Money(765.43m, "USD")); + } + } + + [TestMethod] + public void WhenParsingUSDollarInNetherlands_ThenThisShouldSucceed() + { + // $ symbol is used for multiple currencies + using (new SwitchCulture("nl-NL")) + { + Money dollar; + Money.TryParse("$765,43", Currency.FromCode("USD"), out dollar).Should().BeTrue(); + dollar.Should().Be(new Money(765.43m, "USD")); + } + } + + [TestMethod] + public void WhenInBelgiumDutchSpeaking_ThenThisShouldSucceed() + { + using (new SwitchCulture("nl-BE")) + { + Money euro; + Money.TryParse(" 765,43", Currency.FromCode("EUR"), out euro).Should().BeTrue(); + + euro.Should().Be(new Money(765.43m, "EUR")); + } + } + + [TestMethod] + public void WhenInBelgiumFrenchSpeaking_ThenThisShouldSucceed() + { + using (new SwitchCulture("fr-BE")) + { + Money euro; + Money.TryParse("765,43 ", Currency.FromCode("EUR"), out euro).Should().BeTrue(); + euro.Should().Be(new Money(765.43, "EUR")); + } + } + + [TestMethod] + public void WhenParsingNumberWithoutCurrency_ThenThisShouldSucceed() + { + using (new SwitchCulture("nl-NL")) + { + Money euro; + Money.TryParse("765,43", Currency.FromCode("USD"), out euro).Should().BeTrue(); + euro.Should().Be(new Money(765.43, "USD")); + } + } + + [TestMethod] + public void WhenParsingUSDollarWithEuroCurrency_ThenThisShouldReturnFalse() + { + using (new SwitchCulture("nl-NL")) + { + Money money; + Money.TryParse(" 765,43", Currency.FromCode("USD"), out money).Should().BeFalse(); + money.Should().Be(new Money(0m, Currency.FromCode("XXX"))); + } + } + } } } \ No newline at end of file diff --git a/NodaMoney/Money.cs b/NodaMoney/Money.cs index 1ec9ebb..06363a6 100644 --- a/NodaMoney/Money.cs +++ b/NodaMoney/Money.cs @@ -87,11 +87,17 @@ public Money(decimal amount, Currency currency, MidpointRounding rounding) // TODO: Currency.Z07 and Currency.DOT edge case handeling! if (Currency.DecimalDigits == Currency.DOT) - Amount = Math.Round(amount); - if (Currency.DecimalDigits == Currency.Z07) + { + Amount = Math.Round(amount); + } + else if (Currency.DecimalDigits == Currency.Z07) + { Amount = Math.Round(amount, 1); - - Amount = Math.Round(amount, (int)Currency.DecimalDigits, rounding); + } + else + { + Amount = Math.Round(amount, (int)Currency.DecimalDigits, rounding); + } } // int, uint ([CLSCompliant(false)]) // auto-casting to decimal so not needed From 5b836df0ef47e67da9a7e9b671f3da19fa85838b Mon Sep 17 00:00:00 2001 From: remyvd Date: Sun, 31 May 2015 17:06:45 +0200 Subject: [PATCH 02/19] Starting with #8, Added CurrencyBuilder class and first test --- NodaMoney.UnitTests/CurrencyBuilderTests.cs | 80 ++++++++++++++++ .../NodaMoney.UnitTests.csproj | 1 + NodaMoney/Currency.cs | 2 +- NodaMoney/CurrencyBuilder.cs | 94 +++++++++++++++++++ NodaMoney/NodaMoney.csproj | 1 + 5 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 NodaMoney.UnitTests/CurrencyBuilderTests.cs create mode 100644 NodaMoney/CurrencyBuilder.cs diff --git a/NodaMoney.UnitTests/CurrencyBuilderTests.cs b/NodaMoney.UnitTests/CurrencyBuilderTests.cs new file mode 100644 index 0000000..01ff261 --- /dev/null +++ b/NodaMoney.UnitTests/CurrencyBuilderTests.cs @@ -0,0 +1,80 @@ +using System; +using System.Globalization; + +using FluentAssertions; + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace NodaMoney.UnitTests +{ + public class CurrencyBuilderTests + { + [TestClass] + public class GivenIWantToCreateCustomCurrency + { + [TestMethod] + public void WhenRegisterBitCoin_ThenShouldBeAvailable() + { + var builder = new CurrencyBuilder("BTC", "virtual"); + builder.Code = "BTC"; // ISOCode + builder.EnglishName = "Bitcoin"; + builder.Namespace = "virtual"; + builder.Sign = "฿"; //symbol? + builder.ISONumber = "123"; // iso number + builder.DecimalDigits = 4; + builder.IsObsolete = false; + //builder.IsVirtual = true; or IsCustom or both + //builder.AlternativeSigns = arry[]; + //builder.LegalTender = false; + //builder.ValidFrom = DateTime.Now; or Validity(from/to or until) + //builder.ValidTo = DateTime.Now; + //builder.UsedInCultureRegion.Add(ci); + //builder.NativeName = ""; + //builder.DecimalSeparator = ","; + //builder.GroupSeparator = "."; + //builder.GroupSizes = new int[] { 3, 2 }; + //builder.Priority = 2; + //builder.SubUnit = "Cents"; + //builder.SubUnitToUnit = 100; + //builder.SignFirst = true; + //builder.HtmlEntity = "€"; + //builder.SmallestDenomination = 1; + //numberFormatInfo.Currency + //numberFormatInfo.CurrencyNegativePattern = 12; + //numberFormatInfo.CurrencyPositivePattern = 2; + //numberFormatInfo.CurrencySymbol = "EUR"; + //numberFormatInfo.DigitSubstitution = DigitShapes.None; + + builder.Register(); + + Currency bitcoin = Currency.FromCode("BTC"); + + + bitcoin.Sign.Should().Be("฿"); + } + + //Currency bitcoin = "BTC"; + + //Currency(string code, string number, double decimalDigits, string englishName, string sign) + //{ "AED", new Currency("AED", "784", 2, "United Arab Emirates dirham", "د.إ") }, + + //http://www.codeproject.com/Articles/15175/NET-Internationalization-The-Developer-s-Guide-to + //https://msdn.microsoft.com/en-us/library/system.globalization.cultureandregioninfobuilder%28v=vs.110%29.aspx + // Save to Unicode Technical Standard #35. It is an extensible XML format for the exchange of structured locale data + //builder.Save("en-GB.ldml"); + + //CultureAndRegionInfoBuilder builder = CultureAndRegionInfoBuilder.CreateFromLdml("en-GB.ldml"); + //builder.Register(); + + //CultureAndRegionInfoBuilder.Unregister("en-GB"); + + // load in the data from the existing culture and region + //builder.LoadDataFromCultureInfo(cultureInfo); + //builder.LoadDataFromRegionInfo(regionInfo); + + //foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.UserCustomCulture)) + //CultureTypes.UserCustomCulture + //CultureAndRegionInfoBuilderHelper.Export(new CultureInfo("cy-GB"), "cy-GB.ldml","en-GB", "en-GB"); + } + } +} \ No newline at end of file diff --git a/NodaMoney.UnitTests/NodaMoney.UnitTests.csproj b/NodaMoney.UnitTests/NodaMoney.UnitTests.csproj index b6a17dd..1c0bb53 100644 --- a/NodaMoney.UnitTests/NodaMoney.UnitTests.csproj +++ b/NodaMoney.UnitTests/NodaMoney.UnitTests.csproj @@ -86,6 +86,7 @@ + diff --git a/NodaMoney/Currency.cs b/NodaMoney/Currency.cs index 2a033a7..4b8bae0 100644 --- a/NodaMoney/Currency.cs +++ b/NodaMoney/Currency.cs @@ -24,7 +24,7 @@ public struct Currency : IEquatable, IXmlSerializable // To represent this in decimal we do the following steps: 5 is 10 to the power of log(5) = 0.69897... ~ 0.7 internal const double Z07 = 0.69897000433601880478626110527551; // Math.Log10(5); internal const double DOT = -1; - private static readonly Dictionary Currencies = InitializeIsoCurrencies(); + internal static readonly Dictionary Currencies = InitializeIsoCurrencies(); /// Initializes a new instance of the struct. /// The code. diff --git a/NodaMoney/CurrencyBuilder.cs b/NodaMoney/CurrencyBuilder.cs new file mode 100644 index 0000000..119b822 --- /dev/null +++ b/NodaMoney/CurrencyBuilder.cs @@ -0,0 +1,94 @@ +using System; + +namespace NodaMoney +{ + /// Defines a custom currency that is new or based on another currency. + public class CurrencyBuilder + { + /// Initializes a new instance of the class. + /// The code of the currency, normally the three-character ISO 4217 currency code. + /// The namespace for the currency. + public CurrencyBuilder(string currencyCode, string @namespace) + { + Code = currencyCode; + Namespace = @namespace; + } + + /// Gets or sets the english name of the currency. + public string EnglishName { get; set; } + + /// Gets or sets the currency sign. + public string Sign { get; set; } + + /// Gets or sets the numeric ISO 4217 currency code. + // ReSharper disable once InconsistentNaming + public string ISONumber { get; set; } + + /// Gets or sets the number of digits after the decimal separator. + public int DecimalDigits { get; set; } + + /// Gets or sets the namespace of the currency. + public string Namespace { get; set; } + + /// Gets or sets the code of the currency, normally a three-character ISO 4217 currency code. + public string Code { get; set; } + + /// Gets or sets a value indicating whether currency is obsolete. + /// true if this instance is obsolete; otherwise, false. + public bool IsObsolete { get; set; } + + /// Reconstitutes a object from a specified XML file that contains a + /// representation of the object. + /// A file name that contains the XML representation of a object. + /// A new object that is equivalent to the information stored in the xmlFileName parameter. + public static CurrencyBuilder CreateFromLdml(string xmlFileName) + { + throw new NotImplementedException(); + } + + /// Unregisters the specified currency code from the current AppDomain. + /// The name of the currency to unregister. + /// The namespace of the currency to unregister. + public static void Unregister(string currencyCode, string @namespace) + { + throw new NotImplementedException(); + } + + /// Registers the current object as a custom currency for the current AppDomain. + /// The custom currency is already registered -or- ... + public void Register() + { + var currency = new Currency(Code, ISONumber, DecimalDigits, EnglishName, Sign); + Currency.Currencies.Add(Code, currency); + // new InvalidOperationException() + //throw new NotImplementedException(); + } + + /// Writes an XML representation of the current object to the specified file. + /// The name of a file to contain the XML representation of this custom currency. + /// + /// + /// The Save method writes the current object to the file specified by the + /// filename parameter in an XML format called Locale Data Markup Language (LDML) version 1.1. + /// The method performs the reverse operation of the Save method. + /// + /// + /// For information about the format of an LDML file, see the CreateFromLdml method. For information about the LDML + /// standard, see Unicode Technical Standard #35, "Locale + /// Data Markup Language (LDML)" on the Unicode Consortium website. + /// + /// + public void Save(string filename) + { + throw new NotImplementedException(); + } + + /// Sets the properties of the current object with the corresponding properties of + /// the specified object. + /// The object whose properties will be used. + public void LoadDataFromCurrency(Currency currency) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/NodaMoney/NodaMoney.csproj b/NodaMoney/NodaMoney.csproj index 4063b6a..738f634 100644 --- a/NodaMoney/NodaMoney.csproj +++ b/NodaMoney/NodaMoney.csproj @@ -48,6 +48,7 @@ Properties\SolutionInfo.cs + From 2e0c665578b9b772fcd34cbd217a7ba46c2bf311 Mon Sep 17 00:00:00 2001 From: remyvd Date: Sun, 31 May 2015 17:40:43 +0200 Subject: [PATCH 03/19] Add IsObsolete flag to Currency to be used for historic currencies --- NodaMoney/Currency.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/NodaMoney/Currency.cs b/NodaMoney/Currency.cs index 2a033a7..28bb633 100644 --- a/NodaMoney/Currency.cs +++ b/NodaMoney/Currency.cs @@ -32,9 +32,10 @@ public struct Currency : IEquatable, IXmlSerializable /// The decimal digits. /// Name of the english. /// The sign. + /// Value indicating whether currency is obsolete. /// code or number or englishName or sign is null - /// DecimalDigits of code must be between -1 and 3! - internal Currency(string code, string number, double decimalDigits, string englishName, string sign) + /// DecimalDigits of code must be between -1 and 4! + internal Currency(string code, string number, double decimalDigits, string englishName, string sign, bool isObsolete = false) : this() { if (string.IsNullOrWhiteSpace(code)) @@ -53,6 +54,7 @@ internal Currency(string code, string number, double decimalDigits, string engli DecimalDigits = decimalDigits; EnglishName = englishName; Sign = sign; + IsObsolete = isObsolete; } /// Gets the Currency that represents the country/region used by the current thread. @@ -112,6 +114,10 @@ public decimal MinorUnit } } + /// Gets or sets a value indicating whether currency is obsolete. + /// true if this instance is obsolete; otherwise, false. + public bool IsObsolete { get; private set; } + /// Create an instance of the , based on a ISO 4217 currency code. /// A ISO 4217 currency code, like EUR or USD. /// An instance of the type . From 8f3949a7e9adad14c5bdd4d991d5ec580eb9bced Mon Sep 17 00:00:00 2001 From: remyvd Date: Sun, 31 May 2015 17:56:12 +0200 Subject: [PATCH 04/19] Added LTV, LVL, ZMK, ZWL and EEK as historic currencies (IsObsolete = true) --- NodaMoney.UnitTests/CurrencyTests.cs | 12 ++++++++++++ NodaMoney/Currency.cs | 9 +++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/NodaMoney.UnitTests/CurrencyTests.cs b/NodaMoney.UnitTests/CurrencyTests.cs index bf6771a..03f15b5 100644 --- a/NodaMoney.UnitTests/CurrencyTests.cs +++ b/NodaMoney.UnitTests/CurrencyTests.cs @@ -99,6 +99,7 @@ public void WhenIsoCodeIsExisting_ThenCreatingShouldSucceed() currency.Sign.Should().Be("€"); currency.Code.Should().Be("EUR"); currency.EnglishName.Should().Be("Euro"); + currency.IsObsolete.Should().BeFalse(); } [TestMethod] @@ -116,6 +117,17 @@ public void WhenIsoCodeIsNull_ThenCreatingShouldThrow() action.ShouldThrow(); } + + [TestMethod] + public void WhenEstionianKrone_ThenItShouldBeObsolete() + { + var currency = Currency.FromCode("EEK"); + + currency.Should().NotBeNull(); + currency.Sign.Should().Be("kr"); + currency.IsObsolete.Should().BeTrue(); + } + } [TestClass] diff --git a/NodaMoney/Currency.cs b/NodaMoney/Currency.cs index 28bb633..6b44118 100644 --- a/NodaMoney/Currency.cs +++ b/NodaMoney/Currency.cs @@ -379,8 +379,8 @@ private static Dictionary InitializeIsoCurrencies() { "LKR", new Currency("LKR", "144", 2, "Sri Lankan rupee", "Rs") }, // or රු { "LRD", new Currency("LRD", "430", 2, "Liberian dollar", "$") }, // or L$, LD$ { "LSL", new Currency("LSL", "426", 2, "Lesotho loti", "L") }, // L or M (pl.) - // { "LTL", new Currency("LTL", "440", 2, "Lithuanian litas", "Lt") }, // Until 2014-12-31, replaced by EUR - // { "LVL", new Currency("LVL", "428", 2, "Latvian lats", "Ls") }, // Until 2014-01-15, replaced by EUR + { "LTL", new Currency("LTL", "440", 2, "Lithuanian litas", "Lt", isObsolete: true) }, // Until 2014-12-31, replaced by EUR + { "LVL", new Currency("LVL", "428", 2, "Latvian lats", "Ls", isObsolete: true) }, // Until 2014-01-15, replaced by EUR { "LYD", new Currency("LYD", "434", 3, "Libyan dinar", "ل.د") }, // or LD { "MAD", new Currency("MAD", "504", 2, "Moroccan dirham", "د.م.") }, { "MDL", new Currency("MDL", "498", 2, "Moldovan leu", "L") }, @@ -472,8 +472,9 @@ private static Dictionary InitializeIsoCurrencies() { "YER", new Currency("YER", "886", 2, "Yemeni rial", "﷼") }, // or ر.ي.‏‏ ? { "ZAR", new Currency("ZAR", "710", 2, "South African rand", "R") }, { "ZMW", new Currency("ZMW", "967", 2, "Zambian kwacha", "ZK") }, // or ZMW - // { "ZMK", new Currency("ZMK", "894", 2, "Zambian kwacha", "ZK") } // Until 2013-01-01, replaced by ZWM - { "ZWL", new Currency("ZWL", "932", 2, "Zimbabwean dollar", "$") } // or Z$ (official currency of Zimbabwe from 1980 to 12 April 2009, not used anymore) + { "ZMK", new Currency("ZMK", "894", 2, "Zambian kwacha", "ZK", isObsolete: true) }, // Until 2013-01-01, replaced by ZWM + { "ZWL", new Currency("ZWL", "932", 2, "Zimbabwean dollar", "$", isObsolete: true) }, // or Z$ (official currency of Zimbabwe from 1980 to 12 April 2009, not used anymore) + { "EEK", new Currency("EEK", "233", 2, "Estonian kroon", "kr", isObsolete: true) } // From 1992 Until 2010-12-31, replaced by EUR }; return currencies; From 074840b355d721b9bdb099511b9a1d4a17b290dc Mon Sep 17 00:00:00 2001 From: remyvd Date: Sat, 6 Jun 2015 12:46:46 +0200 Subject: [PATCH 05/19] Implement CurrencyBuilder methods and added tests --- ...ysisDictionary.xml => CustomDictionary.xml | 2 + .../NodaMoney.Serialization.AspNet.csproj | 10 +-- NodaMoney.UnitTests/CurrencyBuilderTests.cs | 81 ++++++++++++++++--- NodaMoney.UnitTests/CurrencyTests.cs | 16 ++-- NodaMoney.sln | 2 +- NodaMoney/Currency.cs | 24 +++--- NodaMoney/CurrencyBuilder.cs | 39 ++++++--- NodaMoney/Money.Formattable.cs | 2 +- NodaMoney/Money.Parsable.cs | 6 +- NodaMoney/NodaMoney.csproj | 10 +-- Settings.StyleCop | 1 + 11 files changed, 133 insertions(+), 60 deletions(-) rename CodeAnalysisDictionary.xml => CustomDictionary.xml (94%) diff --git a/CodeAnalysisDictionary.xml b/CustomDictionary.xml similarity index 94% rename from CodeAnalysisDictionary.xml rename to CustomDictionary.xml index 1b5c280..ee8f231 100644 --- a/CodeAnalysisDictionary.xml +++ b/CustomDictionary.xml @@ -15,6 +15,7 @@ iraimbilanja cinquième ariary + Ldml ComPlus @@ -23,6 +24,7 @@ USDollar + ISO \ No newline at end of file diff --git a/NodaMoney.Serialization.AspNet/NodaMoney.Serialization.AspNet.csproj b/NodaMoney.Serialization.AspNet/NodaMoney.Serialization.AspNet.csproj index 49c9b4f..5c3332c 100644 --- a/NodaMoney.Serialization.AspNet/NodaMoney.Serialization.AspNet.csproj +++ b/NodaMoney.Serialization.AspNet/NodaMoney.Serialization.AspNet.csproj @@ -46,17 +46,17 @@ - - - Properties\CodeAnalysisDictionary.xml - - {1814E8DE-0E75-4E23-9F70-E039AC816B42} NodaMoney + + + Properties\CustomDictionary.xml + +