Exemple #1
0
        public void Run()
        {
            GlobalizationCurrencyInfo[] globalizationInfo = GlobalizationCurrencyInfo
                                                            .LoadFromGlobalization()
                                                            .ToArray();

            CurrencyInfo[] configurationInfo;
            using (var initializer = new EmbeddedXmlInitializer())
            {
                configurationInfo = Enumeration.GetValues <CurrencyIsoCode>()
                                    .Select(c => initializer.Get(c))
                                    .ToArray();
            }

            List <ComparisonTable> tables = new List <ComparisonTable>(3);

            if (MultiCanonical || All)
            {
                tables.Add(new MultiCanonicalTable());
            }
            if (Discrepancies || All)
            {
                tables.Add(new DiscrepanciesTable());
            }
            if (NotCanonical || All)
            {
                tables.Add(new NotCanonicalTable());
            }
            tables.ForEach(t => t.Print(globalizationInfo, configurationInfo));
        }
Exemple #2
0
        private void compareWithConfiguration(IEnumerable <CultureCurrencyInfo> fromGlobalization)
        {
            var writer = new TextMessageWriter();

            using (var initializer = new EmbeddedXmlInitializer())
            {
                foreach (var global in fromGlobalization)
                {
                    CurrencyInfo notGlobal = initializer.Get(global.Info.Code);
                    var          comparer  = new CurrencyInfoComparer(global.Culture);
                    if (!comparer.Equals(global.Info, notGlobal))
                    {
                        CanonicalCultureAttribute attr;
                        Enumeration.TryGetAttribute(notGlobal.Code, out attr);
                        CultureInfo canonical = attr != null?attr.Culture() : null;

                        if (canonical != null && !canonical.Name.Equals(global.Culture.Name))
                        {
                            displayCultureInformation(writer, global, notGlobal);
                        }
                        else
                        {
                            var differences = comparer.ExtendedEquals(global.Info, notGlobal);
                            displayDifferences(global, notGlobal, differences, writer);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void Get_UndefinedCurrency_Exception()
        {
            CurrencyIsoCode notDefined = (CurrencyIsoCode)(-1);

            using (var subject = new EmbeddedXmlInitializer())
            {
                Assert.That(() => subject.Get(notDefined),
                            Throws.InstanceOf <MisconfiguredCurrencyException>().With.Message.Contains("-1"));
            }
        }
Exemple #4
0
 public void Get_DanishKrone_DanishKroneCurrencyInfo()
 {
     using (var subject = new EmbeddedXmlInitializer())
     {
         CurrencyInfo info = subject.Get(CurrencyIsoCode.DKK);
         Assert.That(info, Must.Be.CurrencyInfo()
                     .WithCode(CurrencyIsoCode.DKK)
                     .WithEnglishName("Danish Krone")
                     .WithNativeName("Dansk krone")
                     .WithSymbol("kr.")
                     .WithSignificantDecimalDigits(2)
                     .WithDecimalSeparator(",")
                     .WithGroupSeparator(".")
                     .WithGroupSizes(new[] { 3 })
                     .WithPositivePattern(2)
                     .WithNegativePattern(12));
     }
 }
Exemple #5
0
 public void Get_Euro_EuroCurrencyInfo()
 {
     using (var subject = new EmbeddedXmlInitializer())
     {
         CurrencyInfo info = subject.Get(CurrencyIsoCode.EUR);
         Assert.That(info, Must.Be.CurrencyInfo()
                     .WithCode(CurrencyIsoCode.EUR)
                     .WithEnglishName("Euro")
                     .WithNativeName("Euro")
                     .WithSymbol("€")
                     .WithSignificantDecimalDigits(2)
                     .WithDecimalSeparator(",")
                     .WithGroupSeparator(".")
                     .WithGroupSizes(new[] { 3 })
                     .WithPositivePattern(3)
                     .WithNegativePattern(8));
     }
 }
Exemple #6
0
        public void MultipleCallsToInitializer_AreFasterThan_MultipleCallsToProvider()
        {
            var      provider     = new EmbeddedXmlProvider();
            TimeSpan providerTime = ActionTimer.Time(() =>
            {
                foreach (var code in Enumeration.GetValues <CurrencyIsoCode>())
                {
                    provider.Get(code);
                }
            });

            TimeSpan initializerTime = ActionTimer.Time(() =>
            {
                using (var initializer = new EmbeddedXmlInitializer())
                {
                    foreach (var code in Enumeration.GetValues <CurrencyIsoCode>())
                    {
                        initializer.Get(code);
                    }
                }
            });

            Assert.That(initializerTime, Is.LessThan(providerTime));
        }