-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced specialized
AttributeDictionary
view model for unit tests
The `AttributeDictionaryConstructorTopicViewModel` provides a more specialized model for evaluating the `AttributeDictionary` mapping capabilities added to the `TopicMappingService` (see #99). This builds off of the existing `PageTopicViewModel` by including both a `MappedProperty` (which will get mapped by the constructor) and an `UnmappedProperty` (which will not get mapped by the constructor). This allows us to confirm that the `AttributeDictionary` constructor did, in fact, get called, since otherwise the `UnmappedProperty` would get picked up by `SetPropertyAsync()`. As part of this, I also extended the attributes in the test to ensure that it isn't falling under the recently introduced threshold for honoring the `AttributeDictionary` constructor (2e157e5).
- Loading branch information
1 parent
fabeb82
commit a68d459
Showing
2 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
OnTopic.Tests/ViewModels/AttributeDictionaryConstructorTopicViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*============================================================================================================================== | ||
| Author Ignia, LLC | ||
| Client Ignia, LLC | ||
| Project Topics Library | ||
\=============================================================================================================================*/ | ||
|
||
using OnTopic.Attributes; | ||
|
||
namespace OnTopic.Tests.ViewModels { | ||
|
||
/*============================================================================================================================ | ||
| VIEW MODEL: ATTRIBUTE DICTIONARY CONSTRUCTOR | ||
\---------------------------------------------------------------------------------------------------------------------------*/ | ||
/// <summary> | ||
/// Provides a strongly-typed data transfer object for testing a constructor with a <see cref="AttributeDictionary"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is a sample class intended for test purposes only; it is not designed for use in a production environment. | ||
/// </remarks> | ||
public record AttributeDictionaryConstructorTopicViewModel: PageTopicViewModel { | ||
|
||
/*========================================================================================================================== | ||
| CONSTRUCTOR | ||
\-------------------------------------------------------------------------------------------------------------------------*/ | ||
/// <summary> | ||
/// Initializes a new <see cref="AttributeDictionaryConstructorTopicViewModel"/> with an <paramref name="attributes"/> | ||
/// dictionary. | ||
/// </summary> | ||
/// <param name="attributes">An <see cref="AttributeDictionaryConstructorTopicViewModel"/> of attribute values.</param> | ||
public AttributeDictionaryConstructorTopicViewModel(AttributeDictionary attributes) : base(attributes) { | ||
Contract.Requires(attributes, nameof(attributes)); | ||
MappedProperty = attributes.GetValue(nameof(MappedProperty)); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="AttributeDictionaryConstructorTopicViewModel"/> with no parameters. | ||
/// </summary> | ||
public AttributeDictionaryConstructorTopicViewModel() { } | ||
|
||
/*========================================================================================================================== | ||
| PROPERTIES | ||
\-------------------------------------------------------------------------------------------------------------------------*/ | ||
public string? MappedProperty { get; init; } | ||
public string? UnmappedProperty { get; init; } | ||
|
||
|
||
} //Class | ||
} //Namespace |