@@ -88,6 +88,60 @@ public void AddErrorLabels_should_have_expected_result(
88
88
subject . ErrorLabels . Should ( ) . Equal ( existingErrorLabels . Concat ( new [ ] { newErrorLabel } ) ) ;
89
89
}
90
90
91
+ [ Fact ]
92
+ public void AddErrorLabels_should_not_add_duplicates ( )
93
+ {
94
+ var subject = new MongoException ( _message ) ;
95
+
96
+ subject . AddErrorLabel ( "one" ) ;
97
+ subject . AddErrorLabel ( "one" ) ;
98
+
99
+ subject . ErrorLabels . Should ( ) . HaveCount ( 1 ) ;
100
+ }
101
+
102
+ [ Theory ]
103
+ [ ParameterAttributeData ]
104
+ public void HasErrorLabel_should_have_expected_result (
105
+ [ Values ( 0 , 1 , 2 , 3 ) ] int existingCount )
106
+ {
107
+ var subject = new MongoException ( _message ) ;
108
+ for ( var i = 0 ; i < existingCount ; i ++ )
109
+ {
110
+ var errorLabel = $ "label{ i } ";
111
+ subject . AddErrorLabel ( errorLabel ) ;
112
+ }
113
+
114
+ foreach ( var errorLabel in subject . ErrorLabels )
115
+ {
116
+ subject . HasErrorLabel ( errorLabel ) . Should ( ) . BeTrue ( ) ;
117
+ }
118
+ subject . HasErrorLabel ( "x" ) . Should ( ) . BeFalse ( ) ;
119
+ }
120
+
121
+ [ Theory ]
122
+ [ InlineData ( new string [ 0 ] , "x" ) ]
123
+ [ InlineData ( new [ ] { "one" } , "one" ) ]
124
+ [ InlineData ( new [ ] { "one" } , "x" ) ]
125
+ [ InlineData ( new [ ] { "one" , "two" } , "one" ) ]
126
+ [ InlineData ( new [ ] { "one" , "two" } , "two" ) ]
127
+ [ InlineData ( new [ ] { "one" , "two" } , "x" ) ]
128
+ [ InlineData ( new [ ] { "one" , "two" , "three" } , "one" ) ]
129
+ [ InlineData ( new [ ] { "one" , "two" , "three" } , "two" ) ]
130
+ [ InlineData ( new [ ] { "one" , "two" , "three" } , "three" ) ]
131
+ [ InlineData ( new [ ] { "one" , "two" , "three" } , "x" ) ]
132
+ public void RemoveErrorLabels_should_have_expected_result ( string [ ] errorLabels , string removeErrorLabel )
133
+ {
134
+ var subject = new MongoException ( _message ) ;
135
+ foreach ( var errorLabel in errorLabels )
136
+ {
137
+ subject . AddErrorLabel ( errorLabel ) ;
138
+ }
139
+
140
+ subject . RemoveErrorLabel ( removeErrorLabel ) ;
141
+
142
+ subject . ErrorLabels . Should ( ) . Equal ( errorLabels . Where ( x => x != removeErrorLabel ) ) ;
143
+ }
144
+
91
145
#if NET45
92
146
[ Fact ]
93
147
public void Serialization_should_work ( )
0 commit comments