Exemple #1
0
        public void EnFormat()
        {
            PluralFormatter formatter = new PluralFormatter(new CultureInfo("en-GB"));

            const string NUNIT_TEST_KEY = "nUnit_files";

            try
            {
                formatter.Format(0, NUNIT_TEST_KEY);
                Assert.Fail("������� ��������������� 0.");
            }
            catch { }

            try
            {
                formatter.Format(1, null);
                Assert.Fail("������� ��������������� �� ����� null.");
            }
            catch { }

            Assert.AreEqual("1 file", formatter.Format(1, NUNIT_TEST_KEY));
            Assert.AreEqual("2 files", formatter.Format(2, NUNIT_TEST_KEY));
            Assert.AreEqual("101 files", formatter.Format(101, NUNIT_TEST_KEY));
            Assert.AreEqual("file", formatter.Format(1, NUNIT_TEST_KEY, false));
            Assert.AreEqual("files", formatter.Format(2, NUNIT_TEST_KEY, false));
            Assert.AreEqual("files", formatter.Format(101, NUNIT_TEST_KEY, false));
        }
Exemple #2
0
        public void Constructor()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            PluralFormatter formatter = new PluralFormatter();

            //������������ ��������� ����, ����� ��������� :)
            FieldInfo[] fieldInfo =
                typeof(PluralFormatter).GetFields(BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.Public);

            Assert.AreEqual("Glint.Yttrium.Gui.en_PluralFormatter",
                    (fieldInfo[0].GetValue(formatter).ToString()),
                "�������� �� ��� ���������.");
            Assert.AreEqual("en-US", (fieldInfo[1].GetValue(formatter).ToString()),
                "��������� �� �� ��������.");

            try
            {
                formatter = new PluralFormatter(new CultureInfo("es-ES"));
                Assert.Fail("�� ����� ����� es_ES_PluralFormatter� ������");
            }
            catch { }

            //������ �� ������������ �������� ����� ��������
            formatter = new PluralFormatter(new CultureInfo("en-AU"));
            Assert.AreEqual("Glint.Yttrium.Gui.en_PluralFormatter",
                    (fieldInfo[0].GetValue(formatter).ToString()),
                "�������� �� ��� ���������.");

            //������ ��������� �� ������� ��������
            formatter = new PluralFormatter(new CultureInfo("ru-RU"));
            Assert.AreEqual("Glint.Yttrium.Gui.ru_PluralFormatter",
                (fieldInfo[0].GetValue(formatter).ToString()),
                "�������� �� ��� ���������.");
            Assert.AreEqual("ru-RU", (fieldInfo[1].GetValue(formatter).ToString()),
                "��������� �� �� ��������.");
        }
Exemple #3
0
        public void RuFormat()
        {
            PluralFormatter formatter = new PluralFormatter(new CultureInfo("ru"));

            const string NUNIT_TEST_KEY = "nUnit_files";

            try
            {
                formatter.Format(0, NUNIT_TEST_KEY);
                Assert.Fail("������� ��������������� ����� 0.");
            }
            catch { }

            try
            {
                formatter.Format(1, null);
                Assert.Fail("������� ��������������� �� ����� null.");
            }
            catch { }

            int[] firstVariantNumbers =
            {
                1, 21, 31, 101, 121, 131, 1001, 1021, 1101, 1121,
                1131, 1201, 1221, 1231
            };
            int[] secondVariantNumbers =
            {
                2, 3, 4, 22, 23, 24, 34, 102, 103, 104, 1002, 1003, 1004
            };
            int[] thirdVariantNumbers =
            {
                5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
                20, 25, 26, 105, 106, 110, 111, 112, 117, 120, 125, 126,
                130, 135, 1000, 1005, 1007, 1010, 1011, 1017, 1100, 1105
            };

            foreach (int number in firstVariantNumbers)
                Assert.AreEqual(number + " ����", formatter.Format(number, NUNIT_TEST_KEY));

            foreach (int number in secondVariantNumbers)
                Assert.AreEqual(number + " �����", formatter.Format(number, NUNIT_TEST_KEY));

            foreach (int number in thirdVariantNumbers)
                Assert.AreEqual(number + " ������", formatter.Format(number, NUNIT_TEST_KEY));

            foreach (int number in firstVariantNumbers)
                Assert.AreEqual("����", formatter.Format(number, NUNIT_TEST_KEY, false));

            foreach (int number in secondVariantNumbers)
                Assert.AreEqual("�����", formatter.Format(number, NUNIT_TEST_KEY, false));

            foreach (int number in thirdVariantNumbers)
                Assert.AreEqual("������", formatter.Format(number, NUNIT_TEST_KEY, false));
        }