[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / corlib / Test / System.Reflection / VisibilityTest.cs
blobab540f65e671d4e2ffb43694a5ff24a5f4324931
1 // VisibilityTest.cs
2 //
3 //
4 // Author:
5 // Marius Ungureanu <marius.ungureanu@xamarin.com>
6 //
7 // Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
27 #if !MONOTOUCH && !FULL_AOT_RUNTIME
29 using System;
30 using System.Linq;
31 using System.Reflection;
32 using NUnit.Framework;
33 using System.Collections;
35 namespace MonoTests.System.Reflection.VisibilityTypes
37 [TestFixture]
38 public class VisibilityTests
40 static void DoesNotContain (IEnumerable collection, object val)
42 Assert.That(collection, Has.No.Member(val));
45 static void Contains (IEnumerable collection, object val)
47 Assert.That(collection, Has.Member(val));
50 [Test]
51 public void TestsExportedTypes ()
53 var types = typeof (VisibilityTests).Assembly.GetExportedTypes ();
55 // Test visibility means that the class is public by applying and on the 'public' visibility of the nested items.
56 DoesNotContain (types, typeof (InternalClass));
57 Contains (types, typeof (PublicClass));
59 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+InternalNested", true));
60 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+PrivateNested", true));
61 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+ProtectedNested", true));
62 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+PublicNested", true));
64 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+InternalNested", true));
65 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+PrivateNested", true));
66 DoesNotContain (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+ProtectedNested", true));
67 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+PublicNested", true));
70 [Test]
71 public void TestsModuleTypes ()
73 var types = typeof (VisibilityTests).Module.GetTypes ();
75 // Test that all the types defined exist.
76 Contains (types, typeof (InternalClass));
77 Contains (types, typeof (PublicClass));
79 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+InternalNested", true));
80 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+PrivateNested", true));
81 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+ProtectedNested", true));
82 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+InternalClass+PublicNested", true));
84 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+InternalNested", true));
85 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+PrivateNested", true));
86 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+ProtectedNested", true));
87 Contains (types, Type.GetType ("MonoTests.System.Reflection.VisibilityTypes.VisibilityTests+PublicClass+PublicNested", true));
90 class InternalClass
92 internal class InternalNested {}
93 private class PrivateNested {}
94 protected class ProtectedNested {}
95 public class PublicNested {}
98 public class PublicClass
100 internal class InternalNested {}
101 private class PrivateNested {}
102 protected class ProtectedNested {}
103 public class PublicNested {}
108 #endif