From 85a6c2266bb330972a48b4c546399d28801a024f Mon Sep 17 00:00:00 2001 From: bbaia Date: Tue, 17 Aug 2010 10:19:00 +0000 Subject: [PATCH] Unit Test reproducing SPRNET-1262 --- .../Proxy/AbstractProxyTypeBuilderTests.cs | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs index 5cfd25e8..703248f4 100644 --- a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs +++ b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs @@ -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 {