Add autoconf checks for platforms without IPv6
[mono.git] / mcs / class / monodoc / Test / Monodoc / EcmaDocTests.cs
1 using System;
2 using System.IO;
3 using System.Linq;
4 using System.Reflection;
5 using System.Collections.Generic;
6
7 using NUnit.Framework;
8
9 using Monodoc;
10 using Monodoc.Generators;
11
12 namespace MonoTests.Monodoc
13 {
14         [TestFixture]
15         public class EcmaDocTest
16         {
17                 // Because EcmaDoc is internal and we can't use InternalsVisibleTo since test assemblies aren't
18                 // signed/strong-named by the build, we have to resort to reflection
19                 TDelegate GetTestedMethod<TDelegate> (string methodName)
20                 {
21                         var ecmaDoc = Type.GetType ("Monodoc.Providers.EcmaDoc, monodoc, PublicKey=0738eb9f132ed756");
22                         return (TDelegate)(object)Delegate.CreateDelegate (typeof (TDelegate), ecmaDoc.GetMethod (methodName));
23                 }
24
25                 [Test]
26                 public void CountTypeGenericArgumentsTest ()
27                 {
28                         var realCountTypeGenericArguments = GetTestedMethod<Func<string, int, int>> ("CountTypeGenericArguments");
29                         // Since we don't use the optional start index parameters, bypass it by wrapping the func
30                         Func<string, int> countTypeGenericArguments = s => realCountTypeGenericArguments (s, 0);
31
32                         Assert.AreEqual (0, countTypeGenericArguments ("T:System.String"), "#0a");
33                         Assert.AreEqual (0, countTypeGenericArguments ("T:String"), "#0b");
34                         Assert.AreEqual (0, countTypeGenericArguments ("String"), "#0c");
35
36                         Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo<T>"), "#1a");
37                         Assert.AreEqual (1, countTypeGenericArguments ("T:System.Foo<T>"), "#1b");
38                         Assert.AreEqual (1, countTypeGenericArguments ("T:Foo<T>"), "#1c");
39                         Assert.AreEqual (1, countTypeGenericArguments ("Foo<T>"), "#1d");
40
41                         Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo<T, U>"), "#2a");
42                         Assert.AreEqual (2, countTypeGenericArguments ("T:System.Foo<TKey, TValue>"), "#2b");
43                         Assert.AreEqual (2, countTypeGenericArguments ("T:Foo<Something,Else>"), "#2c");
44                         Assert.AreEqual (2, countTypeGenericArguments ("Foo<TDelegate,TArray>"), "#2d");
45
46                         Assert.AreEqual (3, countTypeGenericArguments ("T:System.Collections.Foo<T, U, V>"), "#3a");
47                         Assert.AreEqual (3, countTypeGenericArguments ("T:System.Foo<TKey, TValue, THash>"), "#3b");
48                         Assert.AreEqual (3, countTypeGenericArguments ("T:Foo<Something,Else,Really>"), "#3c");
49                         Assert.AreEqual (3, countTypeGenericArguments ("Foo<TDelegate,TArray,TEvent>"), "#3d");
50                 }
51
52                 [Test]
53                 public void CountTypeGenericArgumentsTest_Nested ()
54                 {
55                         var realCountTypeGenericArguments = GetTestedMethod<Func<string, int, int>> ("CountTypeGenericArguments");
56                         // Since we don't use the optional start index parameters, bypass it by wrapping the func
57                         Func<string, int> countTypeGenericArguments = s => realCountTypeGenericArguments (s, 0);
58
59                         Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo<T[]>"), "#1a");
60                         Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo<IList<T>>"), "#1b");
61                         Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo<T, KeyValuePair<T, U>>"), "#2a");
62                         Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo<T, KeyValuePair<IProducerConsumerCollection<U>, IEquatable<V>>>"), "#2b");
63                         Assert.AreEqual (3, countTypeGenericArguments ("T:System.Collections.Foo<T, IProducerConsumerCollection<U>, IEquatable<V>>"), "#3a");
64                 }
65         }
66 }