Skip to content

Commit 65c7b9a

Browse files
committed
Established GetContentTypeDescriptors() test
Ensured that `ITopicRepositoryTest` is evaluating the `GetContentTypeDescriptors()` method. This is important since this method has some built-in logic. As part of this, also ensured that `FakeTopicRepository`'s `Load()` and `GetContentTypeDescriptors()` methods were implemented enough to satisfy the test requirements. This included registering all content types in the `FakeTopicRepository` to ensure that internally-created `ContentTypeDescriptor`s had been created (e.g., `Lookup`, `List`, &c.) as well as renaming `ContentType` to `ContentTypeDescriptor`.
1 parent 60bb4f6 commit 65c7b9a

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

Ignia.Topics.Tests/ITopicRepositoryTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ public void Delete() {
189189

190190
}
191191

192+
/*==========================================================================================================================
193+
| TEST: GET CONTENT TYPE DESCRIPTORS
194+
\-------------------------------------------------------------------------------------------------------------------------*/
195+
/// <summary>
196+
/// Retrieves a list of <see cref="ContentTypeDescriptor"/>s from the <see cref="ITopicRepository"/> and ensures that
197+
/// the expected number (2) are present.
198+
/// </summary>
199+
[TestMethod]
200+
public void GetContentTypeDescriptors() {
201+
202+
var contentTypes = _topicRepository.GetContentTypeDescriptors();
203+
204+
Assert.AreEqual<int>(7, contentTypes.Count);
205+
Assert.IsNotNull(contentTypes.GetTopic("ContentTypeDescriptor"));
206+
Assert.IsNotNull(contentTypes.GetTopic("Page"));
207+
Assert.IsNotNull(contentTypes.GetTopic("LookupListItem"));
208+
209+
}
210+
192211

193212
} //Class
194213

Ignia.Topics.Tests/TestDoubles/FakeTopicRepository.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Diagnostics.Contracts;
99
using System.Threading.Tasks;
1010
using Ignia.Topics.Collections;
11+
using Ignia.Topics.Querying;
1112
using Ignia.Topics.Repositories;
1213

1314
namespace Ignia.Topics.Tests.TestDoubles {
@@ -41,14 +42,6 @@ public FakeTopicRepository() : base() {
4142
CreateFakeData();
4243
}
4344

44-
/*==========================================================================================================================
45-
| GET CONTENT TYPE DESCRIPTORS
46-
\-------------------------------------------------------------------------------------------------------------------------*/
47-
/// <summary>
48-
/// Retrieves a collection of Content Type Descriptor objects from the configuration section of the data provider.
49-
/// </summary>
50-
public override ContentTypeDescriptorCollection GetContentTypeDescriptors() => throw new NotImplementedException();
51-
5245
/*==========================================================================================================================
5346
| METHOD: LOAD
5447
\-------------------------------------------------------------------------------------------------------------------------*/
@@ -58,7 +51,9 @@ public FakeTopicRepository() : base() {
5851
/// <param name="topicId">The topic identifier.</param>
5952
/// <param name="isRecursive">Determines whether or not to recurse through and load a topic's children.</param>
6053
/// <returns>A topic object.</returns>
61-
public override Topic Load(int topicId, bool isRecursive = true) => throw new NotImplementedException();
54+
public override Topic Load(int topicId, bool isRecursive = true) {
55+
return (topicId < 0)? _cache :_cache.FindFirst(t => t.Id.Equals(topicId));
56+
}
6257

6358
/// <summary>
6459
/// Loads a topic (and, optionally, all of its descendants) based on the specified key name.
@@ -72,7 +67,8 @@ public override Topic Load(string topicKey = null, bool isRecursive = true) {
7267
| Lookup by TopicKey
7368
\-----------------------------------------------------------------------------------------------------------------------*/
7469
if (!String.IsNullOrWhiteSpace(topicKey)) {
75-
throw new NotImplementedException();
70+
topicKey = topicKey.Contains(":") ? topicKey : "Root:" + topicKey;
71+
return _cache.FindFirst(t => t.GetUniqueKey().Equals(topicKey));
7672
}
7773

7874
/*------------------------------------------------------------------------------------------------------------------------
@@ -233,9 +229,12 @@ private void CreateFakeData() {
233229
var configuration = TopicFactory.Create("Configuration", "Container", rootTopic);
234230
var contentTypes = TopicFactory.Create("ContentTypes", "ContentTypeDescriptor", configuration);
235231

236-
TopicFactory.Create("ContentType", "ContentTypeDescriptor", contentTypes);
232+
TopicFactory.Create("ContentTypeDescriptor", "ContentTypeDescriptor", contentTypes);
237233
TopicFactory.Create("Page", "ContentTypeDescriptor", contentTypes);
238234
TopicFactory.Create("Container", "ContentTypeDescriptor", contentTypes);
235+
TopicFactory.Create("Lookup", "ContentTypeDescriptor", contentTypes);
236+
TopicFactory.Create("LookupListItem", "ContentTypeDescriptor", contentTypes);
237+
TopicFactory.Create("List", "ContentTypeDescriptor", contentTypes);
239238

240239
/*------------------------------------------------------------------------------------------------------------------------
241240
| Establish metadata

0 commit comments

Comments
 (0)