File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -967,6 +967,25 @@ public async Task Map_FilterByAttribute_ReturnsFilteredCollection() {
967967
968968 }
969969
970+ /*==========================================================================================================================
971+ | TEST: MAP: FILTER BY INVALID ATTRIBUTE: THROWS EXCEPTION
972+ \-------------------------------------------------------------------------------------------------------------------------*/
973+ /// <summary>
974+ /// Attempts to map a view model that has an invalid <see cref="FilterByAttributeAttribute.Key"/> value of <c>ContentType
975+ /// </c>; throws an <see cref="ArgumentException"/>.
976+ /// </summary>
977+ [ TestMethod ]
978+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
979+ public async Task Map_FilterByInvalidAttribute_ThrowsExceptions ( ) {
980+
981+ var topic = TopicFactory . Create ( "Test" , "FilteredInvalid" ) ;
982+
983+ var target = await _mappingService . MapAsync < FilteredInvalidTopicViewModel > ( topic ) . ConfigureAwait ( false ) ;
984+
985+ Assert . AreEqual < int > ( 2 , target . Children . Count ) ;
986+
987+ }
988+
970989 /*==========================================================================================================================
971990 | TEST: MAP: FILTER BY CONTENT TYPE: RETURNS FILTERED COLLECTION
972991 \-------------------------------------------------------------------------------------------------------------------------*/
Original file line number Diff line number Diff line change 1+ /*==============================================================================================================================
2+ | Author Ignia, LLC
3+ | Client Ignia, LLC
4+ | Project Topics Library
5+ \=============================================================================================================================*/
6+ using OnTopic . Mapping . Annotations ;
7+ using OnTopic . ViewModels ;
8+ using OnTopic . ViewModels . Collections ;
9+
10+ namespace OnTopic . Tests . ViewModels {
11+
12+ /*============================================================================================================================
13+ | VIEW MODEL: FILTERED TOPIC (INVALID)
14+ \---------------------------------------------------------------------------------------------------------------------------*/
15+ /// <summary>
16+ /// Provides a strongly-typed data transfer object for testing views properties annotated with the <see cref="
17+ /// FilterByAttributeAttribute"/>. Includes an invalid <see cref="FilterByAttributeAttribute"/>.
18+ /// </summary>
19+ /// <remarks>
20+ /// This is a sample class intended for test purposes only; it is not designed for use in a production environment.
21+ /// </remarks>
22+ public class FilteredInvalidTopicViewModel {
23+
24+ [ FilterByAttribute ( "ContentType" , "Page" ) ]
25+ public TopicViewModelCollection < TopicViewModel > Children { get ; } = new ( ) ;
26+
27+ } //Class
28+ } //Namespace
You can’t perform that action at this time.
0 commit comments