Skip to content

Commit 6f825f5

Browse files
committed
Introduced unit tests for GetUnmatchedAttributes()
In a previous commit, we introduced a new `GetUnmatchedAttributes()` method to `TopicRepositoryBase` (2237a02), but neglected to include unit test coverage. As we prepare to extend this functionality, we're including the missing unit tests to ensure that we're not breaking existing functionality in the process. This includes a "proxy" method on `StubTopicRepository` to publicly expose the `protected` `GetUnmatchedAttributes()` method via a `GetUnmatchedAttributesProxy()` passthrough.
1 parent 120c55e commit 6f825f5

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

OnTopic.TestDoubles/StubTopicRepository.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ public override void Move(Topic topic, Topic target, Topic? sibling) {
171171
public IEnumerable<AttributeValue> GetAttributesProxy(Topic topic, bool? isExtendedAttribute, bool? isDirty = null) =>
172172
base.GetAttributes(topic, isExtendedAttribute, isDirty);
173173

174+
/*==========================================================================================================================
175+
| METHOD: GET UNMATCHED ATTRIBUTES (PROXY)
176+
\-------------------------------------------------------------------------------------------------------------------------*/
177+
/// <inheritdoc cref="TopicRepositoryBase.GetUnmatchedAttributes(Topic)" />
178+
public IEnumerable<AttributeDescriptor> GetUnmatchedAttributesProxy(Topic topic) => base.GetUnmatchedAttributes(topic);
179+
174180
/*==========================================================================================================================
175181
| METHOD: CREATE FAKE DATA
176182
\-------------------------------------------------------------------------------------------------------------------------*/

OnTopic.Tests/TopicRepositoryBaseTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@ public void GetAttributes_ExtendedAttributes_ReturnsExtendedAttributes() {
106106

107107
}
108108

109+
/*==========================================================================================================================
110+
| TEST: GET UNMATCHED ATTRIBUTES: RETURNS ATTRIBUTES
111+
\-------------------------------------------------------------------------------------------------------------------------*/
112+
/// <summary>
113+
/// Using <see cref="TopicRepositoryBase.GetUnmatchedAttributes(Topic)"/>, ensures that any attributes that exist on the
114+
/// <see cref="ContentTypeDescriptor"/> but not the <see cref="Topic"/> are returned.
115+
/// </summary>
116+
[TestMethod]
117+
public void GetUnmatchedAttributes_ReturnsAttributes() {
118+
119+
var topic = TopicFactory.Create("Test", "ContentTypeDescriptor", 1);
120+
121+
topic.Attributes.SetValue("Title", "Title");
122+
123+
var attributes = _topicRepository.GetUnmatchedAttributesProxy(topic);
124+
125+
Assert.IsTrue(attributes.Any());
126+
Assert.IsFalse(attributes.Any(a => a.Key.Equals("Title", StringComparison.InvariantCultureIgnoreCase)));
127+
128+
}
129+
109130
/*==========================================================================================================================
110131
| TEST: GET CONTENT TYPE DESCRIPTORS: RETURNS CONTENT TYPES
111132
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)