public void DotNetMethod_FromAssembly_AbstractClassProtectedMethod() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.AbstractClass.MethodProtected()'></member>", LoadOptions.PreserveWhitespace); Type type = typeof(AbstractClass); MethodInfo methodInfo = type.GetDeclaredMethods().First(m => m.Name == "MethodProtected"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual(MethodCategory.Protected, result.Category); }
public void DotNetMethod_FromAssembly_ParamComment() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.ParameterClass.MethodOneNormalParameter(System.Int32)'><param name='a'>Comments</param></member>", LoadOptions.PreserveWhitespace); Type type = typeof(ParameterClass); MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodOneNormalParameter"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual(1, result.ParameterComments.Count); Assert.IsNotNull(result.ParameterComments[0]); }
public void DotNetMethod_FromAssembly_MethodOneGeneric_AddedToMethod() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodOneGeneric``1' />", LoadOptions.PreserveWhitespace); string expectedFullName = "DataFilesTest.DotNetMethodTests.NormalClass.MethodOneGeneric<CustomA>"; Type type = typeof(NormalClass); MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodOneGeneric"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual(expectedFullName, result.Name.FullName); }
public void DotNetMethodOperator_FromAssembly_ExplicitOperator() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodOperatorTests.ClassA.op_Explicit(DataFilesTest.DotNetMethodOperatorTests.ClassA)~System.Int64' />", LoadOptions.PreserveWhitespace); Type type = typeof(ClassA); MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "op_Explicit"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual("System.Single", result.MethodName.ReturnTypeName); Assert.AreEqual("DataFilesTest.DotNetMethodOperatorTests.ClassA", result.MethodName.Parameters[0].TypeName); }
public void DotNetMethod_FromAssembly_ZeroParameters() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.ParameterClass.MethodZeroParameters' />", LoadOptions.PreserveWhitespace); string expectedFullName = "DataFilesTest.DotNetMethodTests.ParameterClass.MethodZeroParameters"; Type type = typeof(ParameterClass); MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodZeroParameters"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual(expectedFullName, result.Name.FullName); Assert.AreEqual(0, result.MethodName.Parameters.Count); }
public void DotNetMethod_FromAssembly_ReturnNestedGeneric() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.NormalClass.MethodReturnNestedGeneric' />", LoadOptions.PreserveWhitespace); string expectedFullName = "DataFilesTest.DotNetMethodTests.NormalClass.MethodReturnNestedGeneric"; string expectedReturnFullName = "DataFilesTest.DotNetMethodTests.GenericOne<System.String>.NestedGeneric<System.Int32>"; Type type = typeof(NormalClass); MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodReturnNestedGeneric"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual(expectedFullName, result.Name.FullName); Assert.AreEqual(expectedReturnFullName, result.MethodName.ReturnTypeName.FullName); }
public void DotNetMethod_FromAssembly_GenericClassGenericMethodOneParameterFromMethod() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.DotNetMethodTests.GenericOne`1.MethodMethodGeneric``1(``0)' />", LoadOptions.PreserveWhitespace); string expectedFullName = "DataFilesTest.DotNetMethodTests.GenericOne<T>.MethodMethodGeneric<A>"; Type type = typeof(GenericOne <>); MethodInfo methodInfo = type.GetMethods().First(m => m.Name == "MethodMethodGeneric"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert Assert.AreEqual(expectedFullName, result.Name.FullName); Assert.AreEqual(1, result.MethodName.Parameters.Count); Assert.AreEqual("A", result.MethodName.Parameters[0].FullTypeName); Assert.AreEqual("a", result.MethodName.Parameters[0].Name); }
public void DotNetMethod_FromAssembly_ExtensionMethodParameters() { //arrange XElement xmlElement = XElement.Parse("<member name='M:DataFilesTest.StaticTestClass.MethodExtension(System.String,System.String)'></member>", LoadOptions.PreserveWhitespace); Type type = typeof(StaticTestClass); MethodInfo methodInfo = type.GetDeclaredMethods().First(m => m.Name == "MethodExtension"); //act DotNetMethod result = DotNetMethod.FromVisualStudioXml(xmlElement); result.AddAssemblyInfo(methodInfo); //assert #if DATAFILES_TARGET_20 || DATAFILES_TARGET_30 Assert.AreEqual(MethodCategory.Static, result.Category); Assert.AreEqual(ParameterCategory.Normal, result.MethodName.Parameters[0].Category); #else Assert.AreEqual(MethodCategory.Extension, result.Category); Assert.AreEqual(ParameterCategory.Extension, result.MethodName.Parameters[0].Category); #endif Assert.AreEqual(ParameterCategory.Normal, result.MethodName.Parameters[1].Category); }