public void NamedTypeTestInterfaceNoEventsNoFieldsSomeMethodsNoNamedTypes() { var namedTypeSymbol = (INamedTypeSymbol)TestResource.GetTestMember("TestLibrary.PublicInterface`1"); NamedTypeApiView publicInterface = new NamedTypeApiView(namedTypeSymbol); Assert.Equal("PublicInterface", publicInterface.Name); Assert.Equal("interface", publicInterface.TypeKind); Assert.Empty(publicInterface.Events); Assert.Empty(publicInterface.Fields); Assert.Equal(3, publicInterface.Methods.Length); Assert.Empty(publicInterface.NamedTypes); }
public void NamedTypeTestClassSomeEventsSomeFieldsNoMethodsSomeNamedTypes() { var namedTypeSymbol = (INamedTypeSymbol)TestResource.GetTestMember("TestLibrary.SomeEventsSomeFieldsNoMethodsSomeNamedTypes"); NamedTypeApiView publicClass = new NamedTypeApiView(namedTypeSymbol); Assert.Equal("SomeEventsSomeFieldsNoMethodsSomeNamedTypes", publicClass.Name); Assert.Equal("class", publicClass.TypeKind); Assert.Equal(2, publicClass.Events.Length); Assert.Equal(2, publicClass.Fields.Length); Assert.Empty(publicClass.Methods); Assert.Equal(2, publicClass.NamedTypes.Length); }
public void NamespaceTestNonGlobalSomeNamedTypesNonamespaces() { AssemblyApiView assembly = new AssemblyApiView(TestResource.GetAssemblySymbol()); Assert.Equal("TestLibrary", assembly.Name); NamespaceApiView globalNamespace = assembly.GlobalNamespace; NamespaceApiView nestedNamespace = globalNamespace.Namespaces[0]; Assert.Equal("TestLibrary", nestedNamespace.Name); Assert.NotEmpty(nestedNamespace.NamedTypes); Assert.Empty(nestedNamespace.Namespaces); }
public void FieldTestProtected() { var fieldSymbol = (IFieldSymbol)TestResource.GetTestMember("TestLibrary.PublicClass", "protectedField"); FieldApiView field = new FieldApiView(fieldSymbol); Assert.Equal("protectedField", field.Name); Assert.Equal("int", field.Type.Tokens[0].DisplayString); Assert.Equal("protected", field.Accessibility); Assert.False(field.IsConstant); Assert.False(field.IsReadOnly); Assert.False(field.IsStatic); Assert.False(field.IsVolatile); Assert.Null(field.Value); }
public void NamedTypeTestImplementsInterface() { var namedTypeSymbol = (INamedTypeSymbol)TestResource.GetTestMember("TestLibrary.ImplementingClass"); NamedTypeApiView implementer = new NamedTypeApiView(namedTypeSymbol); Assert.Equal("ImplementingClass", implementer.Name); Assert.Equal("class", implementer.TypeKind); Assert.Single(implementer.Implementations); Assert.Equal("TestLibrary", implementer.Implementations[0].Tokens[0].DisplayString); Assert.Equal(".", implementer.Implementations[0].Tokens[1].DisplayString); Assert.Equal("PublicInterface", implementer.Implementations[0].Tokens[2].DisplayString); Assert.Equal("<", implementer.Implementations[0].Tokens[3].DisplayString); Assert.Equal("int", implementer.Implementations[0].Tokens[4].DisplayString); Assert.Equal(">", implementer.Implementations[0].Tokens[5].DisplayString); }
public void ParameterTestSomeRefKindNoDefaultValue() { var methodSymbol = (IMethodSymbol)TestResource.GetTestMember("TestLibrary.PublicInterface`1", "RefKindParamMethod"); MethodApiView method = new MethodApiView(methodSymbol); Assert.Single(method.Parameters); var typeParts = method.Parameters[0].Type.Tokens; Assert.Equal(RefKind.Ref, method.Parameters[0].RefKind); Assert.Single(typeParts); Assert.Equal("string", typeParts[0].DisplayString); Assert.Equal(TypeReferenceApiView.TokenType.BuiltInType, typeParts[0].Type); Assert.Equal("str", method.Parameters[0].Name); Assert.Null(method.Parameters[0].ExplicitDefaultValue); }
public void NamedTypeTestExplicitConstructor() { var namedTypeSymbol = (INamedTypeSymbol)TestResource.GetTestMember("TestLibrary.PublicClass"); NamedTypeApiView publicClass = new NamedTypeApiView(namedTypeSymbol); bool constructorFound = false; foreach (MethodApiView method in publicClass.Methods) { if (method.Name.Equals("PublicClass")) { constructorFound = true; } } Assert.True(constructorFound); }
public void MethodTestNoAttributesOneTypeParamMultipleParams() { var methodSymbol = (IMethodSymbol)TestResource.GetTestMember("TestLibrary.PublicInterface`1", "TypeParamParamsMethod"); MethodApiView method = new MethodApiView(methodSymbol); Assert.True(method.IsInterfaceMethod); Assert.False(method.IsStatic); Assert.False(method.IsVirtual); Assert.False(method.IsSealed); Assert.False(method.IsOverride); Assert.True(method.IsAbstract); Assert.False(method.IsExtern); Assert.Equal("int", method.ReturnType.Tokens[0].DisplayString); Assert.Empty(method.Attributes); Assert.Equal(2, method.Parameters.Length); Assert.Single(method.TypeParameters); }