-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathITypeLookupServiceTest.cs
More file actions
79 lines (64 loc) · 4.17 KB
/
ITypeLookupServiceTest.cs
File metadata and controls
79 lines (64 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*==============================================================================================================================
| Author Ignia, LLC
| Client Ignia, LLC
| Project Topics Library
\=============================================================================================================================*/
using OnTopic.Lookup;
using OnTopic.Tests.TestDoubles;
using OnTopic.Tests.ViewModels;
using Xunit;
namespace OnTopic.Tests {
/*============================================================================================================================
| CLASS: TYPE LOOKUP SERVICE TEST
\---------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Provides unit tests for the <see cref="ITypeLookupService"/> interface and its implementations, including the
/// <see cref="StaticTypeLookupService"/> and <see cref="DynamicTypeLookupService"/>.
/// </summary>
[ExcludeFromCodeCoverage]
public class ITypeLookupServiceTest {
/*==========================================================================================================================
| TEST: COMPOSITE: LOOKUP VALID TYPE: RETURNS TYPE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Assembles a new <see cref="CompositeTypeLookupService"/> with two instances of a <see cref="ITypeLookupService"/> and
/// confirms that it returns the expected <see cref="Type"/> for a <see cref="ITypeLookupService.Lookup(String[])"/>
/// query.
/// </summary>
[Fact]
public void Composite_LookupValidType_ReturnsType() {
var lookupServiceA = new FakeViewModelLookupService();
var lookupServiceB = new TopicViewModelLookupService();
var compositeLookup = new CompositeTypeLookupService(lookupServiceA, lookupServiceB);
Assert.Equal(typeof(SlideshowTopicViewModel), compositeLookup.Lookup(nameof(SlideshowTopicViewModel)));
Assert.Equal(typeof(MapToParentTopicViewModel), compositeLookup.Lookup(nameof(MapToParentTopicViewModel)));
Assert.Null(compositeLookup.Lookup(nameof(Topic)));
}
/*==========================================================================================================================
| TEST: DYNAMIC TOPIC VIEW MODEL LOOKUP SERVICE: LOOKUP TOPIC VIEW MODEL: RETURNS FALLBACK VIEW MODEL
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Assembles a new <see cref="DynamicTopicViewModelLookupService"/> and requests a type with the <c>TopicViewModel</c>
/// suffix; confirms it correctly falls back to a type with the <c>ViewModel</c> suffix.
/// </summary>
[Fact]
public void DynamicTopicViewModelLookupService_LookupTopicViewModel_ReturnsFallbackViewModel() {
var lookupService = new DynamicTopicViewModelLookupService();
var topicViewModel = lookupService.Lookup("FallbackTopicViewModel", "FallbackViewModel");
Assert.Equal(typeof(FallbackViewModel), topicViewModel);
}
/*==========================================================================================================================
| TEST: DEFAULT TOPIC VIEW MODEL LOOKUP SERVICE: LOOKUP TOPIC VIEW MODEL: RETURNS FALLBACK VIEW MODEL
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Assembles a new <see cref="TopicViewModelLookupService"/> and requests a type with the <c>TopicViewModel</c>
/// suffix; confirms it correctly falls back to a type with the <c>ViewModel</c> suffix.
/// </summary>
[Fact]
public void TopicViewModelLookupService_LookupTopicViewModel_ReturnsFallbackViewModel() {
var lookupService = new FakeViewModelLookupService();
var topicViewModel = lookupService.Lookup("FallbackTopicViewModel", "FallbackViewModel");
Assert.Equal(typeof(FallbackViewModel), topicViewModel);
}
} //Class
} //Namespace