Skip to content

Commit e824c9c

Browse files
committed
Introduced IsExtendedAttribute support for CreateFakeData()
Previously, while the `StubTopicRepository` introduced a number of common `ContentTypeDescriptor` and `AttributeDescriptor` definitions, it didn't set the `IsExtendedAttribute` definition. In preparation for adding unit tests for `GetAttributes()`, we're introducing support for this by extending the local helper function `addAttribute()`, and factoring that into the definitions. This should remain backwards compatible since no existing tests are relying on or referencing these data.
1 parent 477b628 commit e824c9c

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

OnTopic.TestDoubles/StubTopicRepository.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ private Topic CreateFakeData() {
183183
var configuration = TopicFactory.Create("Configuration", "Container", rootTopic);
184184
var contentTypes = TopicFactory.Create("ContentTypes", "ContentTypeDescriptor", configuration);
185185

186-
addAttribute(contentTypes, "Key", "TextAttribute", true);
187-
addAttribute(contentTypes, "ContentType", "TextAttribute", true);
188-
addAttribute(contentTypes, "Title", "TextAttribute", true);
189-
addAttribute(contentTypes, "TopicId", "TopicReferenceAttribute");
186+
addAttribute(contentTypes, "Key", "TextAttribute", false, true);
187+
addAttribute(contentTypes, "ContentType", "TextAttribute", false, true);
188+
addAttribute(contentTypes, "Title", "TextAttribute", true, true);
189+
addAttribute(contentTypes, "TopicId", "TopicReferenceAttribute", false);
190190

191191
var contentTypeDescriptor = TopicFactory.Create("ContentTypeDescriptor", "ContentTypeDescriptor", contentTypes);
192192

@@ -200,8 +200,8 @@ private Topic CreateFakeData() {
200200

201201
var attributeDescriptor = (ContentTypeDescriptor)TopicFactory.Create("AttributeDescriptor", "ContentTypeDescriptor", contentTypes);
202202

203-
addAttribute(attributeDescriptor, "DefaultValue", "TextAttribute", true);
204-
addAttribute(attributeDescriptor, "IsRequired", "BooleanAttribute", true);
203+
addAttribute(attributeDescriptor, "DefaultValue", "TextAttribute", false, true);
204+
addAttribute(attributeDescriptor, "IsRequired", "TextAttribute", false, true);
205205

206206
TopicFactory.Create("BooleanAttribute", "ContentTypeDescriptor", attributeDescriptor);
207207
TopicFactory.Create("NestedTopicListAttribute", "ContentTypeDescriptor", attributeDescriptor);
@@ -214,29 +214,36 @@ private Topic CreateFakeData() {
214214

215215
addAttribute(pageContentType, "MetaTitle");
216216
addAttribute(pageContentType, "MetaDescription");
217-
addAttribute(pageContentType, "IsHidden");
218-
addAttribute(pageContentType, "TopicReference", "TopicReferenceAttribute");
217+
addAttribute(pageContentType, "IsHidden", "TextAttribute", false);
218+
addAttribute(pageContentType, "TopicReference", "TopicReferenceAttribute", false);
219219

220220
pageContentType.Relationships.SetTopic("ContentTypes", pageContentType);
221221
pageContentType.Relationships.SetTopic("ContentTypes", contentTypeDescriptor);
222222

223223
var contactContentType = TopicFactory.Create("Contact", "ContentTypeDescriptor", contentTypes);
224224

225-
addAttribute(contactContentType, "Name");
226-
addAttribute(contactContentType, "AlternateEmail");
227-
addAttribute(contactContentType, "BillingContactEmail");
225+
addAttribute(contactContentType, "Name", isExtended: false);
226+
addAttribute(contactContentType, "AlternateEmail", isExtended: false);
227+
addAttribute(contactContentType, "BillingContactEmail", isExtended: false);
228228

229229
/*------------------------------------------------------------------------------------------------------------------------
230230
| Local addAttribute() helper function
231231
\-----------------------------------------------------------------------------------------------------------------------*/
232-
AttributeDescriptor addAttribute(Topic contentType, string attributeKey, string editorType = "TextAttribute", bool isRequired = false) {
232+
AttributeDescriptor addAttribute(
233+
Topic contentType,
234+
string attributeKey,
235+
string editorType = "TextAttribute",
236+
bool isExtended = true,
237+
bool isRequired = false
238+
) {
233239
var container = contentType.Children.GetTopic("Attributes");
234240
if (container == null) {
235241
container = TopicFactory.Create("Attributes", "List", contentType);
236242
container.Attributes.SetBoolean("IsHidden", true);
237243
}
238244
var attribute = (AttributeDescriptor)TopicFactory.Create(attributeKey, editorType, currentAttributeId++, container);
239245
attribute.IsRequired = isRequired;
246+
attribute.IsExtendedAttribute = isExtended;
240247
return attribute;
241248
}
242249

0 commit comments

Comments
 (0)