Merge pull request #3528 from BrzVlad/fix-sgen-check-before-collections
[mono.git] / mcs / class / corlib / Test / System / DelegateTest.cs
index 0d164f572726796081ffc23ad4054b6048f6239f..ba664353ab9e0056492a1ae525057969609af25e 100644 (file)
@@ -1251,7 +1251,7 @@ namespace MonoTests.System
                        }
                }
        
-               delegate int IntNoArgs ();
+               public delegate int IntNoArgs ();
 
                [Test]
                public void CreateDelegateWithAbstractMethods ()
@@ -1424,6 +1424,39 @@ namespace MonoTests.System
                }
 #endif
 
+               public delegate void DoExecuteDelegate1 (C c);
+               public delegate void DoExecuteDelegate2 (C c);
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void DelegateCombineDifferentTypes () {
+                       var b = new B ();
+                       var del1 = new DoExecuteDelegate1 (b.DoExecute);
+                       var del2 = new DoExecuteDelegate2 (b.DoExecute);
+                       var del = Delegate.Combine (del1, del2);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void DelegateRemoveDifferentTypes () {
+                       var b = new B ();
+                       var del1 = new DoExecuteDelegate1 (b.DoExecute);
+                       var del2 = new DoExecuteDelegate2 (b.DoExecute);
+                       var del = Delegate.Remove (del1, del2);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateDelegateThrowsAnArgumentExceptionWhenCalledWithAnOpenGeneric()
+               {
+                       var m = GetType().GetMethod("AnyGenericMethod");
+                       Delegate.CreateDelegate(typeof(Action), this, m);
+               }
+
+               public void AnyGenericMethod<T>()
+               {
+               }
+
                static bool Int32D2 (int x, int y)
                {
                        return (x & y) == y;