Skip to content

Commit 45aa7be

Browse files
committed
Updated StubTopicRepository so all topics are "saved" by default
Generally, when querying an `ITopicRepository`, it's safe to assume that the topics retuned will be saved. If they aren't, there are a number of issues that can arise since `IsNew` topics will always return `IsDirty()`, among other factors. Most of the topics in the `StubTopicRepository` already have an `Id` assigned to them to simulate that they've been saved, but a number do not. This update ensures all of them have an identity assigned. As suspected, this uncovers some issues with the unit tests. It appears at least two tests which were previously passing now fail. These have been logged as Issues #81 and #82. Those will be addressed in subsequent commits.
1 parent 7fc9436 commit 45aa7be

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

OnTopic.TestDoubles/StubTopicRepository.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,21 +234,21 @@ private Topic CreateFakeData() {
234234
/*------------------------------------------------------------------------------------------------------------------------
235235
| Establish root
236236
\-----------------------------------------------------------------------------------------------------------------------*/
237-
var rootTopic = new Topic("Root", "Container", null, 900);
238237
var currentAttributeId = 800;
238+
var rootTopic = new Topic("Root", "Container", null, currentAttributeId++);
239239

240240
/*------------------------------------------------------------------------------------------------------------------------
241241
| Establish configuration
242242
\-----------------------------------------------------------------------------------------------------------------------*/
243-
var configuration = new Topic("Configuration", "Container", rootTopic);
244-
var contentTypes = new ContentTypeDescriptor("ContentTypes", "ContentTypeDescriptor", configuration);
243+
var configuration = new Topic("Configuration", "Container", rootTopic, currentAttributeId++);
244+
var contentTypes = new ContentTypeDescriptor("ContentTypes", "ContentTypeDescriptor", configuration, currentAttributeId++);
245245

246246
addAttribute(contentTypes, "Key", "TextAttributeDescriptor", false, true);
247247
addAttribute(contentTypes, "ContentType", "TextAttributeDescriptor", false, true);
248248
addAttribute(contentTypes, "Title", "TextAttributeDescriptor", true, true);
249249
addAttribute(contentTypes, "BaseTopic", "TopicReferenceAttributeDescriptor", false);
250250

251-
var contentTypeDescriptor = new ContentTypeDescriptor("ContentTypeDescriptor", "ContentTypeDescriptor", contentTypes);
251+
var contentTypeDescriptor = new ContentTypeDescriptor("ContentTypeDescriptor", "ContentTypeDescriptor", contentTypes, currentAttributeId++);
252252

253253
addAttribute(contentTypeDescriptor, "ContentTypes", "RelationshipAttributeDescriptor");
254254
addAttribute(contentTypeDescriptor, "Attributes", "NestedTopicListAttributeDescriptor");
@@ -258,7 +258,7 @@ private Topic CreateFakeData() {
258258
TopicFactory.Create("LookupListItem", "ContentTypeDescriptor", contentTypes);
259259
TopicFactory.Create("List", "ContentTypeDescriptor", contentTypes);
260260

261-
var attributeDescriptor = new ContentTypeDescriptor("AttributeDescriptor", "ContentTypeDescriptor", contentTypes);
261+
var attributeDescriptor = new ContentTypeDescriptor("AttributeDescriptor", "ContentTypeDescriptor", contentTypes, currentAttributeId++);
262262

263263
addAttribute(attributeDescriptor, "DefaultValue", "TextAttributeDescriptor", false, true);
264264
addAttribute(attributeDescriptor, "IsRequired", "TextAttributeDescriptor", false, true);
@@ -270,7 +270,7 @@ private Topic CreateFakeData() {
270270
TopicFactory.Create("TextAttributeDescriptor", "ContentTypeDescriptor", attributeDescriptor);
271271
TopicFactory.Create("TopicReferenceAttributeDescriptor", "ContentTypeDescriptor", attributeDescriptor);
272272

273-
var pageContentType = new ContentTypeDescriptor("Page", "ContentTypeDescriptor", contentTypes);
273+
var pageContentType = new ContentTypeDescriptor("Page", "ContentTypeDescriptor", contentTypes, currentAttributeId++);
274274

275275
addAttribute(pageContentType, "MetaTitle");
276276
addAttribute(pageContentType, "MetaDescription");
@@ -280,7 +280,7 @@ private Topic CreateFakeData() {
280280
pageContentType.Relationships.SetValue("ContentTypes", pageContentType);
281281
pageContentType.Relationships.SetValue("ContentTypes", contentTypeDescriptor);
282282

283-
var contactContentType = new ContentTypeDescriptor("Contact", "ContentTypeDescriptor", contentTypes);
283+
var contactContentType = new ContentTypeDescriptor("Contact", "ContentTypeDescriptor", contentTypes, currentAttributeId++);
284284

285285
addAttribute(contactContentType, "Name", isExtended: false);
286286
addAttribute(contactContentType, "AlternateEmail", isExtended: false);
@@ -310,9 +310,9 @@ AttributeDescriptor addAttribute(
310310
/*------------------------------------------------------------------------------------------------------------------------
311311
| Establish metadata
312312
\-----------------------------------------------------------------------------------------------------------------------*/
313-
var metadata = new Topic("Metadata", "Container", configuration);
314-
var categories = new Topic("Categories", "Lookup", metadata);
315-
var lookup = new Topic("LookupList", "List", categories);
313+
var metadata = new Topic("Metadata", "Container", configuration, currentAttributeId++);
314+
var categories = new Topic("Categories", "Lookup", metadata, currentAttributeId++);
315+
var lookup = new Topic("LookupList", "List", categories, currentAttributeId++);
316316

317317
for (var i=1; i<=5; i++) {
318318
_ = new Topic("Category" + i, "LookupListItem", lookup);
@@ -325,10 +325,10 @@ AttributeDescriptor addAttribute(
325325

326326
CreateFakeData(web, 2, 3);
327327

328-
var pageGroup = new Topic("Web_3", "PageGroup", web);
329-
_ = new Topic("Web_3_0", "Page", pageGroup);
330-
var childPage = new Topic("Web_3_1", "Page", pageGroup);
331-
var leafPage = new Topic("Web_3_1_0", "Page", childPage);
328+
var pageGroup = new Topic("Web_3", "PageGroup", web, currentAttributeId++);
329+
_ = new Topic("Web_3_0", "Page", pageGroup, currentAttributeId++);
330+
var childPage = new Topic("Web_3_1", "Page", pageGroup, currentAttributeId++);
331+
var leafPage = new Topic("Web_3_1_0", "Page", childPage, currentAttributeId++);
332332

333333
leafPage.Attributes.SetValue("NavigationRoot", "Configuration");
334334

0 commit comments

Comments
 (0)