public void ReadableTypeOutputFactory_GetCustomAttributes_ExtensionMethod() { var members = typeof(SomeExtensionMethod).GetMembers(PublicApiHelpers.VisibleMembers).ToList(); members.Should().NotBeEmpty(); var attributes = ReadableTypeOutputFactory.GetCustomAttributesList(members[0].GetCustomAttributes(true)); attributes.Should().NotBeEmpty(); attributes[0].Should().BeEquivalentTo("[System.Runtime.CompilerServices.ExtensionAttribute]"); }
public void ReadableTypeOutputFactory_GetCustomAttributes_RegularMethod_NoAttributes() { var type = typeof(SomeGenericClass <string>); var members = type.GetMembers(PublicApiHelpers.VisibleMembers).ToList(); members.Should().NotBeEmpty(); var methodInfo = members.OfType <MethodInfo>().Where(c => !c.Name.Contains("_")).FirstOrDefault(); var attributes = ReadableTypeOutputFactory.GetCustomAttributesList(methodInfo.GetCustomAttributes(true)); attributes.Should().BeEmpty("We have not added any custom attributes to our ToString override."); }