Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CultureTest.cs « System.Resources « Test « Managed.Windows.Forms « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c9e65114ce3b56da7e21025c46641620ae6eaf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// CultureTest.cs: Test cases for culture-invariant string convertions
//
// Authors:
//     Robert Jordan <robertj@gmx.net>
//

using System;
using System.Collections;
using System.Globalization;
using System.Drawing;
using System.IO;
using System.Resources;
using System.Threading;
using NUnit.Framework;

namespace MonoTests.System.Resources
{
        [TestFixture]
        public class CultureTest
        {
                string fileName = Path.GetTempFileName ();

                [Test]
                public void TestWriter ()
                {
                        Thread.CurrentThread.CurrentCulture =
                                Thread.CurrentThread.CurrentUICulture = new CultureInfo ("de-DE");

                        ResXResourceWriter w = new ResXResourceWriter (fileName);
                        w.AddResource ("point", new Point (42, 43));
                        w.Generate ();
                        w.Close ();
                }

                [Test]
                public void TestReader ()
                {
                        Thread.CurrentThread.CurrentCulture =
                                Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

                        int count = 0;
                        ResXResourceReader r = new ResXResourceReader (fileName);
                        IDictionaryEnumerator e = r.GetEnumerator ();
                        while (e.MoveNext ()) {
                                if ((string)e.Key == "point") {
                                        Assert.AreEqual (typeof (Point), e.Value.GetType (), "#1");
                                        Point p = (Point) e.Value;
                                        Assert.AreEqual (42, p.X, "#2");
                                        Assert.AreEqual (43, p.Y, "#3");
                                        count++;
                                }
                        }
                        r.Close ();
                        File.Delete (fileName);
                        Assert.AreEqual (1, count, "#100");
                }
        }
}