Skip to content

Commit fc5bb9a

Browse files
committed
Introduced unit test for validating IsFullyLoaded behavior
This unit test creates a `TopicsDataTable` as well as a `TopicReferencesDataTable` with an invalid topic reference, passing them to the `LoadTopicGraph()` extension method, and ensuring that the (private) `SetReferences()` extension method correctly sets the `TopicReferenceDictionary` as `!IsFullyLoaded` since one of the relationships could not be correctly set.
1 parent 56d98cc commit fc5bb9a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

OnTopic.Tests/SqlTopicRepositoryTest.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,34 @@ public void LoadTopicGraph_WithExternalReference_ReturnsReference() {
160160

161161
}
162162

163+
/*==========================================================================================================================
164+
| TEST: LOAD TOPIC GRAPH: WITH MISSING REFERENCE: NOT FULLY LOADED
165+
\-------------------------------------------------------------------------------------------------------------------------*/
166+
/// <summary>
167+
/// Calls <see cref="SqlDataReaderExtensions.LoadTopicGraph(IDataReader, Topic?, Boolean?, Boolean)"/> with a <see cref="
168+
/// TopicReferencesDataTable"/> record that is missing and confirms that <see cref="TopicRelationshipMultiMap.
169+
/// IsFullyLoaded"/> returns <c>false</c>.
170+
/// </summary>
171+
[TestMethod]
172+
public void LoadTopicGraph_WithMissingReference_NotFullyLoaded() {
173+
174+
using var topics = new TopicsDataTable();
175+
using var empty = new AttributesDataTable();
176+
using var references = new TopicReferencesDataTable();
177+
178+
topics.AddRow(1, "Root", "Container", null);
179+
references.AddRow(1, "Test", 2);
180+
181+
using var tableReader = new DataTableReader(new DataTable[] { topics, empty, empty, empty, references });
182+
183+
var topic = tableReader.LoadTopicGraph();
184+
185+
Assert.IsNotNull(topic);
186+
Assert.AreEqual<int>(1, topic.Id);
187+
Assert.AreEqual<int>(0, topic.References.Count);
188+
Assert.IsFalse(topic.References.IsFullyLoaded);
189+
190+
}
191+
163192
} //Class
164193
} //Namespace

0 commit comments

Comments
 (0)