@@ -45,6 +45,17 @@ public void description_of_type_name_rule()
45
45
rule . ToString ( ) . ShouldBe ( "Message name is 'CoreTests.Runtime.RandomClass'" ) ;
46
46
}
47
47
48
+ [ Fact ]
49
+ public void description_of_attribute_rule ( )
50
+ {
51
+ var rule = new Subscription
52
+ {
53
+ BaseOrAttributeType = typeof ( RandomClassAttribute ) ,
54
+ Scope = RoutingScope . Attribute
55
+ } ;
56
+ rule . ToString ( ) . ShouldBe ( "Message type is decorated with 'CoreTests.Runtime.RandomClassAttribute' or a derived type" ) ;
57
+ }
58
+
48
59
[ Fact ]
49
60
public void description_of_all_types ( )
50
61
{
@@ -85,6 +96,20 @@ public void positive_assembly_test()
85
96
rule . Matches ( typeof ( DeleteUser ) ) . ShouldBeTrue ( ) ;
86
97
}
87
98
99
+ [ Fact ]
100
+ public void negative_attribute_test ( )
101
+ {
102
+ var rule = new Subscription
103
+ {
104
+ Scope = RoutingScope . Attribute ,
105
+ BaseOrAttributeType = typeof ( GreenAttribute )
106
+ } ;
107
+
108
+ rule . Matches ( typeof ( GreenMessage1 ) ) . ShouldBeFalse ( ) ;
109
+ rule . Matches ( typeof ( GreenMessage2 ) ) . ShouldBeFalse ( ) ;
110
+ rule . Matches ( typeof ( GreenMessage3 ) ) . ShouldBeFalse ( ) ;
111
+ }
112
+
88
113
[ Fact ]
89
114
public void positive_namespace_test ( )
90
115
{
@@ -98,6 +123,23 @@ public void positive_namespace_test()
98
123
rule . Matches ( typeof ( RedMessage2 ) ) . ShouldBeTrue ( ) ;
99
124
rule . Matches ( typeof ( RedMessage3 ) ) . ShouldBeTrue ( ) ;
100
125
}
126
+
127
+ [ Fact ]
128
+ public void positive_attribute_test ( )
129
+ {
130
+ var rule = new Subscription
131
+ {
132
+ Scope = RoutingScope . Attribute ,
133
+ BaseOrAttributeType = typeof ( RedAttribute )
134
+ } ;
135
+
136
+ rule . Matches ( typeof ( RedMessage1 ) ) . ShouldBeTrue ( ) ;
137
+ rule . Matches ( typeof ( RedMessage2 ) ) . ShouldBeTrue ( ) ;
138
+ rule . Matches ( typeof ( RedMessage3 ) ) . ShouldBeTrue ( ) ;
139
+ }
101
140
}
102
141
103
- public class RandomClass ;
142
+ [ RandomClass ]
143
+ public class RandomClass ;
144
+
145
+ public class RandomClassAttribute : Attribute ;
0 commit comments