コード例 #1
0
        public void LocaleConverter_InvalidToLocale()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            Assert.ThrowsException <InvalidOperationException>(() =>
                                                               localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "en-us", "na-na"));
            Assert.ThrowsException <InvalidOperationException>(() =>
                                                               localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "en-us", "Weird Locale"));
            Assert.ThrowsException <InvalidOperationException>(() =>
                                                               localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "en-us", "fr-"));
            Assert.ThrowsException <ArgumentNullException>(() =>
                                                           localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "en-us", String.Empty));
            Assert.ThrowsException <ArgumentNullException>(() =>
                                                           localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "en-us", null));
        }
コード例 #2
0
        public void LocaleConverter_InvalidFromLocale()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            Assert.ThrowsException <InvalidOperationException>(() =>
                                                               localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "na-na", "en-us"));
        }
コード例 #3
0
        public void LocaleConverter_DateOnly()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("02/03/2010", "en-us", "fr-fr");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("03/02/2010", convertedMessage);
        }
コード例 #4
0
        public void LocaleConverter_DateAndTime()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("half past 9 am 02/03/2010", "en-us", "fr-fr");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("03/02/2010 09:30", convertedMessage);
        }
コード例 #5
0
        public void LocaleConverter_ConvertTimeFromSpanishSpain()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("Book a meeting for 15:00", "es-es", "en-us");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("Book a meeting for 3:00 PM", convertedMessage);
        }
コード例 #6
0
        public void LocaleConverter_ConvertToChinese()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("Book me a plane ticket for France on 12/25/2018", "en-us", "zh-cn");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("Book me a plane ticket for France on 2018/12/25", convertedMessage);
        }
コード例 #7
0
        public void LocaleConverter_TimeRange()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("from 9 am to 1 pm", "en-us", "fr-fr");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("09:00 - 13:00", convertedMessage);
        }
コード例 #8
0
        public void LocaleConverter_ConvertFromFrench()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("Set a meeting on 30/9/2017", "fr-fr", "en-us");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("Set a meeting on 9/30/2017", convertedMessage);
        }
コード例 #9
0
        public void LocaleConverter_DateRange()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("from 10/21/2018 to 10/23/2018", "en-us", "fr-fr");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("21/10/2018 - 23/10/2018", convertedMessage);
        }
コード例 #10
0
        public void LocaleConverter_DateAndTimeRange()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("from 10/21/2018 9 am to 10/23/2018 1 pm", "en-us", "fr-fr");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("21/10/2018 09:00 - 23/10/2018 13:00", convertedMessage);
        }
コード例 #11
0
        public void LocaleConverter_TimeOnly()
        {
            LocaleConverter localeConverter = LocaleConverter.Converter;

            var convertedMessage = localeConverter.Convert("half past 9 am", "en-us", "fr-fr");

            Assert.IsNotNull(convertedMessage);
            Assert.AreEqual("09:30", convertedMessage);
        }