public void IndirectionDelegate_should_get_the_delegate_type_that_indicates_the_method_that_has_a_type_as_same_as_declaring_type_variation() { // Arrange var name = "FugaIndirectionStubTestDOfBarRef"; var alias = "FugaIndirectionStubTestDOfBarRef"; var xml = string.Empty; var target = typeof(D <>).GetMethods().First(); var stub = new IndirectionStub(name, alias, xml, target); // Act var indDlgt = stub.IndirectionDelegate; // Assert var invokeMeth = indDlgt.GetMethod("Invoke"); { var genericType = invokeMeth.GetParameters()[1].ParameterType.GetElementType().GetElementType().GetGenericArguments()[0].GetElementType(); Assert.AreEqual(typeof(D <>).ToString(), genericType.ToString()); Assert.AreNotEqual(typeof(D <>), genericType); } { var genericType = invokeMeth.ReturnType.GetElementType().GetGenericArguments()[0].GetElementType(); Assert.AreEqual(typeof(D <>).ToString(), genericType.ToString()); Assert.AreNotEqual(typeof(D <>), genericType); } }
public void IndirectionDelegate_should_get_the_delegate_type_that_indicates_the_ctor_of_generic_struct() { // Arrange var name = "ConstructorT"; var alias = "ConstructorT"; var xml = string.Empty; var target = typeof(Nullable <>).GetConstructors().First(); var stub = new IndirectionStub(name, alias, xml, target); // Act var indDlgt = stub.IndirectionDelegate; // Assert Assert.AreEqual("Urasandesu.Prig.Delegates.IndirectionRefThisAction`2[System.Nullable`1[T],T]", indDlgt.ToString()); var genericType = indDlgt.GetMethod("Invoke").GetParameters()[0].ParameterType.GetElementType(); Assert.AreEqual(typeof(Nullable <>).ToString(), genericType.ToString()); Assert.AreNotEqual(typeof(Nullable <>), genericType); }
public void IndirectionDelegate_should_get_the_delegate_type_that_indicates_the_method_that_has_a_type_as_same_as_declaring_type_excluding_this() { // Arrange var name = "FugaIndirectionStubTestCOfBar"; var alias = "FugaIndirectionStubTestCOfBar"; var xml = string.Empty; var target = typeof(C <>).GetMethods().First(); var stub = new IndirectionStub(name, alias, xml, target); // Act var indDlgt = stub.IndirectionDelegate; // Assert Assert.AreEqual("Urasandesu.Prig.Delegates.IndirectionFunc`3[Test.Urasandesu.Prig.Framework.PilotStubberConfiguration.IndirectionStubTest+C`1[Bar]," + "Test.Urasandesu.Prig.Framework.PilotStubberConfiguration.IndirectionStubTest+C`1[Bar]," + "Test.Urasandesu.Prig.Framework.PilotStubberConfiguration.IndirectionStubTest+C`1[Bar]]", indDlgt.ToString()); var invokeMeth = indDlgt.GetMethod("Invoke"); { var genericType = invokeMeth.GetParameters()[0].ParameterType; Assert.AreEqual(typeof(C <>).ToString(), genericType.ToString()); Assert.AreNotEqual(typeof(C <>), genericType); } { var genericType = invokeMeth.GetParameters()[1].ParameterType; Assert.AreEqual(typeof(C <>).ToString(), genericType.ToString()); Assert.AreNotEqual(typeof(C <>), genericType); } { var genericType = invokeMeth.ReturnType; Assert.AreEqual(typeof(C <>).ToString(), genericType.ToString()); Assert.AreNotEqual(typeof(C <>), genericType); } }