public void VerifyThatExpectedNumberFormatIsReturned()
        {
            var excelNumberFormatInfo = ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(false, ".", ",");

            Assert.AreEqual(".", excelNumberFormatInfo.NumberDecimalSeparator);
            Assert.AreEqual(",", excelNumberFormatInfo.NumberGroupSeparator);
        }
        public void VerifyThatArgumentExceptionsAreThrown()
        {
            Assert.Throws <ArgumentException>(() => ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(false, null, "."));
            Assert.Throws <ArgumentException>(() => ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(false, string.Empty, "."));

            Assert.Throws <ArgumentException>(() => ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(false, ".", null));
            Assert.Throws <ArgumentException>(() => ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(false, ".", string.Empty));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Queries the appropriate <see cref="NumberFormatInfo"/> based on the decimal separator and thousands separator of the excel application
        /// </summary>
        /// <param name="application">
        /// The current excel application object
        /// </param>
        /// <returns>
        /// an instance of <see cref="NumberFormatInfo"/>
        /// </returns>
        private NumberFormatInfo QuerayNumberFormatInfo(Application application)
        {
            NumberFormatInfo numberFormatInfo = null;

            if (application.UseSystemSeparators)
            {
                numberFormatInfo = ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(true);
            }
            else
            {
                var decimalSeparator   = (string)application.International(XlApplicationInternational.xlDecimalSeparator);
                var thousandsSeparator = (string)application.International(XlApplicationInternational.xlThousandsSeparator);

                numberFormatInfo = ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(false, decimalSeparator, thousandsSeparator);
            }

            return(numberFormatInfo);
        }
        public void VerifyThatIfSystemSeparatorsAreUsedExpectedNumberFormatInfoIsReturned()
        {
            var excelNumberFormatInfo = ExcelNumberFormatProvider.CreateExcelNumberFormatInfo(true);

            Assert.AreEqual(",", excelNumberFormatInfo.NumberDecimalSeparator);
        }