summaryrefslogtreecommitdiff
path: root/tests/src/baseservices/threading/currentculture/culturechangesecurity.cs
blob: 50d127ae314c6dc0bfbaafaeceda8c73aa1c20e2 (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
60
61
62
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Threading;
using System.Globalization;

public class CultureChangeSecurity
{
    public static int Main(string[] args)
    {
        bool status = true;

        status &= Scenario1();
        status &= Scenario2();

        if (!status)
        {
            Console.WriteLine("Test Failed");
            return 101;
        }
        else
        {
            Console.WriteLine("Test Passed!");
            return 100;
        }
    }

    public static bool Scenario1()
    {
        Console.WriteLine("Scenario1: Ensure user code can access Globalization.CultureInfo.CurrentCulture");

        try
        {
            CultureInfo ci = System.Globalization.CultureInfo.CurrentCulture;
            return true;
        }
        catch (Exception e)
        {
            Console.WriteLine("Fail - Got unexpected Exception: " + e);
            return false;
        }
    }

    public static bool Scenario2()
    {
        Console.WriteLine("Scenario2: Ensure user code can access Globalization.CultureInfo.CurrentUICulture");

        try
        {
            CultureInfo ci = System.Globalization.CultureInfo.CurrentUICulture;
            return true;
        }
        catch (Exception e)
        {
            Console.WriteLine("Fail - Got unexpected Exception: " + e);
            return false;
        }
    }
}