File: CppWinRtFormatterTests.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,456 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,089; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (146 lines) | stat: -rw-r--r-- 4,653 bytes parent folder | download | duplicates (5)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using Mono.Cecil;
using Mono.Documentation.Updater.CppFormatters;
using Mono.Documentation.Updater.Formatters.CppFormatters;
using Mono_DocTest;
using Mono_DocTest_Generic;
using NUnit.Framework;

namespace mdoc.Test
{
    [TestFixture]
    public class CppWinRtFormatterTests : BasicFormatterTests<CppWinRtMemberFormatter>
    {
        private static readonly CppWinRtMemberFormatter CppWinRtMemberFormatter = new CppWinRtMemberFormatter();
        protected override CppWinRtMemberFormatter formatter => CppWinRtMemberFormatter;

        private string _cppCxTestLibName = "../../../../external/Test/UwpTestWinRtComponentCpp.winmd";
        private const string CSharpTestLib = "../../../../external/Test/CSharpExample.dll";

        protected override TypeDefinition GetType(Type type)
        {
            var moduleName = type.Module.FullyQualifiedName;

            var tref = GetType(moduleName, type.FullName?.Replace("+", "/"));
            return tref;
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_enum()
        {
            TestTypeSignature(_cppCxTestLibName, "UwpTestWinRtComponentCpp.Color1", "enum Color1");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_publicSealedClass_Class1()
        {
            TestTypeSignature(_cppCxTestLibName, "UwpTestWinRtComponentCpp.Class1",
                "class Class1 sealed");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_publicUnsealedClass_Class2()
        {
            TestTypeSignature(_cppCxTestLibName, "Namespace2.Class2", @"class Class2 : winrt::Windows::UI::Xaml::Application");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_Struct_Class4()
        {
            TestTypeSignature(_cppCxTestLibName, "Namespace2.Class4", "struct Class4");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_GenericInterface()
        {
            TestTypeSignature(typeof(IFoo<>), @"template <typename T>
__interface IFoo");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_GenericClass()
        {
            TestTypeSignature(typeof(MyList<>.Helper<,>), @"template <typename U, typename V>
[Windows::Foundation::Metadata::WebHostHidden]
class MyList<T>::Helper");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_NestedClass()
        {
            TestTypeSignature(typeof(Widget.NestedClass.Double), @"[Windows::Foundation::Metadata::WebHostHidden]
class Widget::NestedClass::Double");
        }

        [Test]
        [Category("Type")]
        public void TypeSignature_WebHostHiddenAttribute()
        {
            TestTypeSignature(typeof(Widget), @"[Windows::Foundation::Metadata::WebHostHidden]
class Widget : Mono_DocTest::IProcess");
        }

        [Test]
        [Category("NoSupport")]
        public void NoSupport_Delegate()
        {
            TestTypeSignature(_cppCxTestLibName, "UwpTestWinRtComponentCpp.PrimeFoundHandlerWithSpecificType", null);
        }
        
        [Test]
        [Category("NoSupport")]
        public void NoSupport_DelegateWithCustomType()
        {
            TestTypeSignature(_cppCxTestLibName, "UwpTestWinRtComponentCpp.SomethingHappenedEventHandler",
                null);
        }

        [Test]
        [Category("NoSupport")]
        public void NoSupport_CustomAttribute()
        {
            TestTypeSignature(_cppCxTestLibName, "UwpTestWinRtComponentCpp.CustomAttribute1", null);
        }

        [Test]
        [Category("NoSupport")]
        public void NoSupport_CustomException()
        {
            TestTypeSignature(typeof(CustomException), null);
        }

        [Test]
        [Category("NoSupport")]
        public void NoSupport_Exception_ArgumentNullExceptionField()
        {
            TestFieldSignature(typeof(CustomException), null, "ArgumentNullExceptionField");
        }

        [Test]
        [Category("NoSupport")]
        public void NoSupport_Exception_InterfaceWithGenericConstraints()
        {
            TestTypeSignature(typeof(IFooNew<>), null);
        }

        [Test]
        [Category("NoSupport")]
        public void NoSupport_Exception_ClassWithGenericConstraints()
        {
            TestTypeSignature(typeof(GenericConstraintClass<>), null);
        }
        [Test]
        [Category("NoSupport")]
        public void NoSupport_Exception_NestedClassWithSameName()
        {
            TestTypeSignature(CSharpTestLib, "Mono.DocTest.Widget/NestedClass", null);
        }
    }
}