@@ -163,6 +163,55 @@ public void Cannot_add_resource_that_implements_only_non_generic_IIdentifiable()
163
163
. WithMessage ( $ "Resource type '{ typeof ( ResourceWithoutId ) } ' implements 'IIdentifiable', but not 'IIdentifiable<TId>'.") ;
164
164
}
165
165
166
+ [ Fact ]
167
+ public void Can_remove_existing_resource_type ( )
168
+ {
169
+ // Arrange
170
+ var options = new JsonApiOptions ( ) ;
171
+ var builder = new ResourceGraphBuilder ( options , NullLoggerFactory . Instance ) ;
172
+ builder . Add < ResourceWithHasOneRelationship , int > ( ) ;
173
+ builder . Add < ResourceWithAttribute , int > ( ) ;
174
+
175
+ // Act
176
+ builder . Remove < ResourceWithHasOneRelationship > ( ) ;
177
+
178
+ // Assert
179
+ IResourceGraph resourceGraph = builder . Build ( ) ;
180
+ resourceGraph . GetResourceTypes ( ) . Should ( ) . ContainSingle ( ) . Which . ClrType . Should ( ) . Be < ResourceWithAttribute > ( ) ;
181
+ }
182
+
183
+ [ Fact ]
184
+ public void Can_remove_missing_resource_type ( )
185
+ {
186
+ // Arrange
187
+ var options = new JsonApiOptions ( ) ;
188
+ var builder = new ResourceGraphBuilder ( options , NullLoggerFactory . Instance ) ;
189
+ builder . Add < ResourceWithAttribute , int > ( ) ;
190
+
191
+ // Act
192
+ builder . Remove < ResourceWithHasManyRelationship > ( ) ;
193
+
194
+ // Assert
195
+ IResourceGraph resourceGraph = builder . Build ( ) ;
196
+ resourceGraph . GetResourceTypes ( ) . Should ( ) . ContainSingle ( ) . Which . ClrType . Should ( ) . Be < ResourceWithAttribute > ( ) ;
197
+ }
198
+
199
+ [ Fact ]
200
+ public void Can_remove_non_resource_type ( )
201
+ {
202
+ // Arrange
203
+ var options = new JsonApiOptions ( ) ;
204
+ var builder = new ResourceGraphBuilder ( options , NullLoggerFactory . Instance ) ;
205
+ builder . Add < ResourceWithAttribute , int > ( ) ;
206
+
207
+ // Act
208
+ builder . Remove ( typeof ( NonResource ) ) ;
209
+
210
+ // Assert
211
+ IResourceGraph resourceGraph = builder . Build ( ) ;
212
+ resourceGraph . GetResourceTypes ( ) . Should ( ) . ContainSingle ( ) . Which . ClrType . Should ( ) . Be < ResourceWithAttribute > ( ) ;
213
+ }
214
+
166
215
[ Fact ]
167
216
public void Cannot_build_graph_with_missing_related_HasOne_resource ( )
168
217
{
0 commit comments