Skip to content

Commit 3e2780b

Browse files
committed
Reduced FakeTopicRepository's descendents
Was previously creating 27 topics under `/Web`. Reduced this to 12 to shore up performance of the tests. (It doesn't reduce it that dramatically, but it does help.)
1 parent dabc79f commit 3e2780b

10 files changed

Lines changed: 46 additions & 47 deletions

File tree

Ignia.Topics.Data.Caching/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
[assembly: AssemblyTrademark("")]
2222
[assembly: AssemblyCulture("")]
2323
[assembly: ComVisible(false)]
24-
[assembly: AssemblyVersion("3.5.1741.0")]
25-
[assembly: AssemblyFileVersion("3.5.1773.0")]
24+
[assembly: AssemblyVersion("3.5.1743.0")]
25+
[assembly: AssemblyFileVersion("3.5.1775.0")]
2626
[assembly: CLSCompliant(true)]
2727
[assembly: Guid("206b7f91-ca25-4e9d-9576-60d2e54a2c0a")]
2828

Ignia.Topics.Tests/ITopicRepositoryTest.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ public void ITopicRepository_MoveTest() {
121121
var rootTopic = _topicRepository.Load();
122122
var source = _topicRepository.Load("Root:Web:Web_0");
123123
var destination = _topicRepository.Load("Root:Web:Web_1");
124-
var topic = _topicRepository.Load("Root:Web:Web_0:Web_0_2");
124+
var topic = _topicRepository.Load("Root:Web:Web_0:Web_0_1");
125125

126126
Assert.ReferenceEquals(topic.Parent, source);
127-
Assert.AreEqual<int>(3, destination.Children.Count());
128-
Assert.AreEqual<int>(3, source.Children.Count());
127+
Assert.AreEqual<int>(2, destination.Children.Count());
128+
Assert.AreEqual<int>(2, source.Children.Count());
129129

130130
_topicRepository.Move(topic, destination);
131131

132132
Assert.ReferenceEquals(topic.Parent, destination);
133-
Assert.AreEqual<int>(2, source.Children.Count());
134-
Assert.AreEqual<int>(4, destination.Children.Count());
133+
Assert.AreEqual<int>(1, source.Children.Count());
134+
Assert.AreEqual<int>(3, destination.Children.Count());
135135

136136
}
137137

@@ -151,12 +151,12 @@ public void ITopicRepository_MoveToSiblingTest() {
151151

152152
Assert.ReferenceEquals(topic.Parent, parent);
153153
Assert.AreEqual<string>("Web_0_0", parent.Children.First().Key);
154-
Assert.AreEqual<int>(3, parent.Children.Count());
154+
Assert.AreEqual<int>(2, parent.Children.Count());
155155

156156
_topicRepository.Move(topic, parent, sibling);
157157

158158
Assert.ReferenceEquals(topic.Parent, parent);
159-
Assert.AreEqual<int>(3, parent.Children.Count());
159+
Assert.AreEqual<int>(2, parent.Children.Count());
160160
Assert.AreEqual<string>("Web_0_1", parent.Children.First().Key);
161161
Assert.AreEqual<string>("Web_0_0", parent.Children[1].Key);
162162

@@ -171,18 +171,18 @@ public void ITopicRepository_MoveToSiblingTest() {
171171
[TestMethod]
172172
public void ITopicRepository_DeleteTest() {
173173

174-
var parent = _topicRepository.Load("Root:Web:Web_2");
175-
var topic = _topicRepository.Load("Root:Web:Web_2:Web_2_2");
176-
var child = _topicRepository.Load("Root:Web:Web_2:Web_2_2:Web_2_2_0");
174+
var parent = _topicRepository.Load("Root:Web:Web_1");
175+
var topic = _topicRepository.Load("Root:Web:Web_1:Web_1_1");
176+
var child = _topicRepository.Load("Root:Web:Web_1:Web_1_1:Web_1_1_0");
177177

178-
Assert.AreEqual<int>(3, parent.Children.Count());
178+
Assert.AreEqual<int>(2, parent.Children.Count());
179179

180180
_topicRepository.Delete(topic);
181181

182-
Assert.AreEqual<int>(2, parent.Children.Count());
182+
Assert.AreEqual<int>(1, parent.Children.Count());
183183

184-
topic = _topicRepository.Load("Root:Web:Web_2:Web_2_2");
185-
child = _topicRepository.Load("Root:Web:Web_2:Web_2_2:Web_2_2_0");
184+
topic = _topicRepository.Load("Root:Web:Web_1:Web_1_1");
185+
child = _topicRepository.Load("Root:Web:Web_1:Web_1_1:Web_1_1_0");
186186

187187
Assert.IsNull(topic);
188188
Assert.IsNull(child);

Ignia.Topics.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[assembly: AssemblyTrademark("")]
2222
[assembly: AssemblyCulture("")]
2323
[assembly: ComVisible(false)]
24-
[assembly: AssemblyVersion("3.5.1747.0")]
25-
[assembly: AssemblyFileVersion("3.5.1795.0")]
24+
[assembly: AssemblyVersion("3.5.1762.0")]
25+
[assembly: AssemblyFileVersion("3.5.1810.0")]
2626
[assembly: CLSCompliant(true)]
2727
[assembly: Guid("27632801-bfe3-41d9-8678-3c4bbe45e6c9")]

Ignia.Topics.Tests/TestDoubles/FakeTopicRepository.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
| Project Topics Library
55
\=============================================================================================================================*/
66
using System;
7+
using System.Collections.Generic;
78
using System.Diagnostics.Contracts;
9+
using System.Threading.Tasks;
810
using Ignia.Topics.Collections;
911
using Ignia.Topics.Repositories;
1012

@@ -251,7 +253,7 @@ private void CreateFakeData() {
251253
\-----------------------------------------------------------------------------------------------------------------------*/
252254
var web = TopicFactory.Create("Web", "Page", 10000, rootTopic);
253255

254-
CreateFakeData(web, 3, 3);
256+
CreateFakeData(web, 2, 3);
255257

256258
/*------------------------------------------------------------------------------------------------------------------------
257259
| Set to cache

Ignia.Topics.Tests/TopicControllerTest.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public class TopicControllerTest {
3434
| PRIVATE VARIABLES
3535
\-------------------------------------------------------------------------------------------------------------------------*/
3636
ITopicRepository _topicRepository = null;
37+
RouteData _routeData = new RouteData();
38+
Uri _uri = new Uri("http://localhost/Web/Web_0/Web_0_1/Web_0_1_1");
39+
Topic _topic = null;
3740

3841
/*==========================================================================================================================
3942
| CONSTRUCTOR
@@ -45,10 +48,12 @@ public class TopicControllerTest {
4548
/// This uses the <see cref="FakeTopicRepository"/> to provide data, and then <see cref="CachedTopicRepository"/> to
4649
/// manage the in-memory representation of the data. While this introduces some overhead to the tests, the latter is a
4750
/// relatively lightweight façade to any <see cref="ITopicRepository"/>, and prevents the need to duplicate logic for
48-
/// crawling the object graph.
51+
/// crawling the object graph. In addition, it initializes a shared <see cref="Topic"/> reference to use for the various
52+
/// tests.
4953
/// </remarks>
5054
public TopicControllerTest() {
51-
_topicRepository = new CachedTopicRepository(new FakeTopicRepository());
55+
_topicRepository = new CachedTopicRepository(new FakeTopicRepository());
56+
_topic = _topicRepository.Load("Root:Web:Web_0:Web_0_1:Web_0_1_1");
5257
}
5358

5459
/*==========================================================================================================================
@@ -60,15 +65,11 @@ public TopicControllerTest() {
6065
[TestMethod]
6166
public async Task TopicController_IndexTestAsync() {
6267

63-
var routes = new RouteData();
64-
var uri = new Uri("http://localhost/Web/Web_0/Web_0_1/Web_0_1_1");
65-
var topic = _topicRepository.Load("Root:Web:Web_0:Web_0_1:Web_0_1_1");
66-
67-
var topicRoutingService = new MvcTopicRoutingService(_topicRepository, uri, routes);
68+
var topicRoutingService = new MvcTopicRoutingService(_topicRepository, _uri, _routeData);
6869
var mappingService = new TopicMappingService(_topicRepository, new FakeViewModelLookupService());
6970

7071
var controller = new TopicController(_topicRepository, topicRoutingService, mappingService);
71-
var result = await controller.IndexAsync(topic.GetWebPath()) as TopicViewResult;
72+
var result = await controller.IndexAsync(_topic.GetWebPath()) as TopicViewResult;
7273
var model = result.Model as PageTopicViewModel;
7374

7475
Assert.IsNotNull(model);
@@ -201,22 +202,18 @@ public void SitemapController_IndexTest() {
201202
[TestMethod]
202203
public async Task LayoutController_MenuTest() {
203204

204-
var routes = new RouteData();
205-
var uri = new Uri("http://localhost/Web/Web_0/Web_0_1/Web_0_1_1");
206-
var topic = _topicRepository.Load("Root:Web:Web_0:Web_0_1:Web_0_1_1");
207-
208-
var topicRoutingService = new MvcTopicRoutingService(_topicRepository, uri, routes);
205+
var topicRoutingService = new MvcTopicRoutingService(_topicRepository, _uri, _routeData);
209206
var mappingService = new TopicMappingService(_topicRepository, new FakeViewModelLookupService());
210207

211208
var controller = new LayoutController(_topicRepository, topicRoutingService, mappingService);
212209
var result = await controller.Menu() as PartialViewResult;
213210
var model = result.Model as NavigationViewModel<NavigationTopicViewModel>;
214211

215212
Assert.IsNotNull(model);
216-
Assert.AreEqual<string>(topic.GetUniqueKey(), model.CurrentKey);
213+
Assert.AreEqual<string>(_topic.GetUniqueKey(), model.CurrentKey);
217214
Assert.AreEqual<string>("Root:Web", model.NavigationRoot.UniqueKey);
218-
Assert.AreEqual<int>(3, model.NavigationRoot.Children.Count());
219-
Assert.IsTrue(model.NavigationRoot.IsSelected(topic.GetUniqueKey()));
215+
Assert.AreEqual<int>(2, model.NavigationRoot.Children.Count());
216+
Assert.IsTrue(model.NavigationRoot.IsSelected(_topic.GetUniqueKey()));
220217

221218
}
222219

Ignia.Topics.Tests/TopicRoutingServiceTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public void TopicRoutingService_TopicRouteTest() {
5757
var topic = _topicRepository.Load("Root:Web:Web_0:Web_0_1:Web_0_1_1");
5858

5959
routes.Values.Add("rootTopic", "Web");
60-
routes.Values.Add("path", "Web_0/Web_0_1/Web_0_1_2");
60+
routes.Values.Add("path", "Web_0/Web_0_1/Web_0_1_1");
6161

6262
var topicRoutingService = new MvcTopicRoutingService(_topicRepository, uri, routes);
6363
var currentTopic = topicRoutingService.GetCurrentTopic();
6464

6565
Assert.IsNotNull(currentTopic);
6666
Assert.ReferenceEquals(topic, currentTopic);
67-
Assert.AreEqual<string>("Web_0_1_2", currentTopic.Key);
67+
Assert.AreEqual<string>("Web_0_1_1", currentTopic.Key);
6868

6969
}
7070

@@ -105,14 +105,14 @@ public void TopicRoutingService_RoutesTest() {
105105
var uri = new Uri("http://localhost/Web/Web_0/Web_0_1/Web_0_1_1");
106106

107107
routes.Values.Add("rootTopic", "Web");
108-
routes.Values.Add("path", "Web_0/Web_0_1/Web_0_1_2");
108+
routes.Values.Add("path", "Web_0/Web_0_1/Web_0_1_1");
109109

110110
var topicRoutingService = new MvcTopicRoutingService(_topicRepository, uri, routes);
111111
var currentTopic = topicRoutingService.GetCurrentTopic();
112112

113113
Assert.IsNotNull(currentTopic);
114114
Assert.AreEqual<string>("Web", routes.GetRequiredString("rootTopic"));
115-
Assert.AreEqual<string>("Web_0/Web_0_1/Web_0_1_2", routes.GetRequiredString("path"));
115+
Assert.AreEqual<string>("Web_0/Web_0_1/Web_0_1_1", routes.GetRequiredString("path"));
116116
Assert.AreEqual<string>("Page", routes.GetRequiredString("contenttype"));
117117

118118
}

Ignia.Topics.ViewModels/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
[assembly: AssemblyTrademark("")]
2222
[assembly: AssemblyCulture("")]
2323
[assembly: ComVisible(false)]
24-
[assembly: AssemblyVersion("3.5.1742.0")]
25-
[assembly: AssemblyFileVersion("3.5.1773.0")]
24+
[assembly: AssemblyVersion("3.5.1744.0")]
25+
[assembly: AssemblyFileVersion("3.5.1775.0")]
2626
[assembly: CLSCompliant(true)]
2727
[assembly: Guid("e52fc633-b4c5-4a2b-8caf-30e756d7a6a7")]
2828

Ignia.Topics.Web.Mvc/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[assembly: AssemblyTrademark("")]
2222
[assembly: AssemblyCulture("")]
2323
[assembly: ComVisible(false)]
24-
[assembly: AssemblyVersion("3.5.1745.0")]
25-
[assembly: AssemblyFileVersion("3.5.1777.0")]
24+
[assembly: AssemblyVersion("3.5.1748.0")]
25+
[assembly: AssemblyFileVersion("3.5.1780.0")]
2626
[assembly: CLSCompliant(true)]
2727
[assembly: Guid("3b3ce34d-b5e5-47ca-bfef-e6740650f378")]

Ignia.Topics.Web/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[assembly: AssemblyTrademark("")]
2222
[assembly: AssemblyCulture("")]
2323
[assembly: ComVisible(false)]
24-
[assembly: AssemblyVersion("3.5.1741.0")]
25-
[assembly: AssemblyFileVersion("3.5.1765.0")]
24+
[assembly: AssemblyVersion("3.5.1742.0")]
25+
[assembly: AssemblyFileVersion("3.5.1766.0")]
2626
[assembly: CLSCompliant(true)]
2727
[assembly: Guid("c98f7b48-a085-4394-b820-c244f23868ce")]

Ignia.Topics/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
[assembly: AssemblyTrademark("")]
2323
[assembly: AssemblyCulture("")]
2424
[assembly: ComVisible(false)]
25-
[assembly: AssemblyVersion("3.5.1741.0")]
26-
[assembly: AssemblyFileVersion("3.5.1773.0")]
25+
[assembly: AssemblyVersion("3.5.1743.0")]
26+
[assembly: AssemblyFileVersion("3.5.1775.0")]
2727
[assembly: InternalsVisibleTo("Ignia.Topics.Tests")]
2828
[assembly: CLSCompliant(true)]
2929
[assembly: GuidAttribute("3CA9F6CB-B45A-4E74-AAA4-0C87CAA2704F")]

0 commit comments

Comments
 (0)