Unit Test reproducing SPRNET-1262

This commit is contained in:
bbaia
2010-08-17 10:19:00 +00:00
parent 5d5500a02a
commit 85a6c2266b

View File

@@ -131,6 +131,27 @@ namespace Spring.Proxy
"Custom attribute not applied to member method.");
}
[Test]
[Ignore]
// SPRNET-1262
public void AppliesSpecificTypeAttributeWithNoPropertySettersToTargetType()
{
IProxyTypeBuilder builder = GetProxyBuilder();
builder.TargetType = typeof(ClassWithFakeServiceKnownTypeAttribute);
builder.TypeAttributes.Add(new FakeServiceKnownTypeAttribute(typeof(TestObject)));
Type proxy = builder.BuildProxyType();
Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to BuildProxy() was null.");
object[] attrs = proxy.GetCustomAttributes(false);
Assert.IsNotNull(attrs, "Should have had 1 attribute applied to the target type.");
Assert.AreEqual(1, attrs.Length, "Should have had 1 attribute applied to the target type.");
Assert.AreEqual(typeof(FakeServiceKnownTypeAttribute), attrs[0].GetType(), "Wrong System.Type of Attribute applied to the target type.");
FakeServiceKnownTypeAttribute fgsta = attrs[0] as FakeServiceKnownTypeAttribute;
Assert.AreEqual(typeof(TestObject), fgsta.Type);
}
[Test]
public void ImplementsInterfaceHierarchy()
{
@@ -754,6 +775,57 @@ namespace Spring.Proxy
}
}
public sealed class FakeServiceKnownTypeAttribute : Attribute
{
private Type declaringType;
private string methodName;
private Type type;
private FakeServiceKnownTypeAttribute()
{
}
public FakeServiceKnownTypeAttribute(string methodName)
{
this.methodName = methodName;
}
public FakeServiceKnownTypeAttribute(Type type)
{
this.type = type;
}
public FakeServiceKnownTypeAttribute(string methodName, Type declaringType)
{
this.methodName = methodName;
this.declaringType = declaringType;
}
public Type DeclaringType
{
get
{
return this.declaringType;
}
}
public string MethodName
{
get
{
return this.methodName;
}
}
public Type Type
{
get
{
return this.type;
}
}
}
public class ClassWithFakeXmlElementAttribute : ISomeMarkerInterface
{
public string MarkerMethod([FakeXmlElement("parameter1")] int param1, string param2)
@@ -773,6 +845,11 @@ namespace Spring.Proxy
{
}
//[FakeServiceKnownTypeAttribute(typeof(TestObject))]
public class ClassWithFakeServiceKnownTypeAttribute : IMarkerInterface
{
}
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=296032
public class ClassWithPublicEnumPropertyAttribute : ISomeMarkerInterface
{