Commit 852a33e
committed
Fixed bug when querying root
When we introduced the `Topic.GetTopicByUniqueKey()` extension method (f2cb109), we significantly optimized the implementation relative to the previous, analogous implementation in `CachedTopicRepository.GetTopic()` (867b110). In doing so, however, we also introduced an inadvertent loophole: It fails to return the unique topic is the unique topic is the root topic.
This is easily remedied by checking this condition at the top of the `GetTopicByUniqueKey()` method. In addition, to be safe, I introduced two unit tests for this scenario. One is for the extension itself (as part of `TopicQueryingTest`). The other is for another extension method, `TopicRepositoryExtensions.Load()` (via `TopicRepositoryExtensionsTest`) which currently relies on that extension method.
(In practice, these two unit tests are evaluating the same underlying logic and are, thus, redundant. But in the past we've modified the underlying logic used by `TopicRepositoryExtensions.Load()`, and so it's useful to evaluate this at that level as well.)1 parent aa63b4a commit 852a33e
3 files changed
Lines changed: 48 additions & 0 deletions
File tree
- OnTopic.AspNetCore.Mvc.Tests
- OnTopic.Tests
- OnTopic/Querying
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
68 | 90 | | |
69 | 91 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
67 | 86 | | |
68 | 87 | | |
69 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
196 | 203 | | |
197 | 204 | | |
198 | 205 | | |
| |||
0 commit comments