diff options
author | katsiaryna_bialiatka <katsiaryna_bialiatka@epam.com> | 2017-12-22 19:15:31 +0300 |
---|---|---|
committer | Joel Martinez <joelmartinez@gmail.com> | 2018-01-12 01:11:42 +0300 |
commit | 6533035ec31f38543532568bc499aba2a98e1788 (patch) | |
tree | c9e7e3bdefd3299bfbf28dd5bd6b5bcc43fd988f /mdoc/mdoc.Test/CppWinRtFormatterTests.cs | |
parent | 8ff2931c4e40e1c3687e8efa6fb4e8078b3a3c4b (diff) |
[mdoc] Support for C++ signatures
Closes #132
Diffstat (limited to 'mdoc/mdoc.Test/CppWinRtFormatterTests.cs')
-rw-r--r-- | mdoc/mdoc.Test/CppWinRtFormatterTests.cs | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/mdoc/mdoc.Test/CppWinRtFormatterTests.cs b/mdoc/mdoc.Test/CppWinRtFormatterTests.cs new file mode 100644 index 00000000..0a2b361d --- /dev/null +++ b/mdoc/mdoc.Test/CppWinRtFormatterTests.cs @@ -0,0 +1,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); + } + } +} |