diff --git a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs index 703248f4..5fcbebea 100644 --- a/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs +++ b/test/Spring/Spring.Core.Tests/Proxy/AbstractProxyTypeBuilderTests.cs @@ -149,7 +149,30 @@ namespace Spring.Proxy 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); + Assert.AreEqual(typeof(TestObject), fgsta.Type, "Property 'Type' on Target Attribute not set!"); + } + + [Test] + // SPRNET-1262 + public void AppliesSpecificTypeAttributeWithNoPropertySettersToTargetTypeUsingCustomAttributeBuilder() + { + ConstructorInfo ci = typeof(FakeServiceKnownTypeAttribute).GetConstructor(new Type[] { typeof(Type) }); + CustomAttributeBuilder cab = new CustomAttributeBuilder(ci, new object[] { typeof(TestObject) }); + + IProxyTypeBuilder builder = GetProxyBuilder(); + builder.TargetType = typeof(ClassWithFakeServiceKnownTypeAttribute); + builder.TypeAttributes.Add(cab); + + 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, "Property 'Type' on Target Attribute not set!"); } [Test] @@ -176,10 +199,10 @@ namespace Spring.Proxy { IProxyTypeBuilder builder = GetProxyBuilder(); builder.TargetType = typeof(ClassWithGuidAttribute); - + 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."); @@ -902,8 +925,8 @@ namespace Spring.Proxy // SPRNET-1134 public class MultipleMarkerClass : ISomeMarkerInterface { - [return: Marker(Count=0)] - [return: Marker(Count=1)] + [return: Marker(Count = 0)] + [return: Marker(Count = 1)] public string MarkerMethod(int param1, [Marker(Count = 0)][Marker(Count = 1)]string param2) { return string.Empty; @@ -979,7 +1002,7 @@ namespace Spring.Proxy } } - [AttributeUsage(AttributeTargets.All, AllowMultiple=true)] + [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public sealed class MarkerAttribute : Attribute { private int _count;