@@ -23,7 +23,7 @@ public void WithViewEngineShouldNotThrowExceptionWithValidViewEngine()
23
23
}
24
24
25
25
[ Fact ]
26
- public void WithViewEngineShouldNotThrowExceptionWithNullViewEngine ( )
26
+ public void WithViewEngineShouldNotThrowExceptionWithNullViewEngineForGeneric ( )
27
27
{
28
28
MyViewComponent < ViewResultComponent >
29
29
. InvokedWith ( c => c . Invoke ( "Test" ) )
@@ -32,6 +32,16 @@ public void WithViewEngineShouldNotThrowExceptionWithNullViewEngine()
32
32
. WithViewEngineOfType < CompositeViewEngine > ( ) ;
33
33
}
34
34
35
+ [ Fact ]
36
+ public void WithViewEngineShouldNotThrowExceptionWithNullViewEngine ( )
37
+ {
38
+ MyViewComponent < ViewResultComponent >
39
+ . InvokedWith ( c => c . Invoke ( "Test" ) )
40
+ . ShouldReturn ( )
41
+ . View ( "SomeView" )
42
+ . WithViewEngineOfType ( typeof ( CompositeViewEngine ) ) ;
43
+ }
44
+
35
45
[ Fact ]
36
46
public void WithViewEngineShouldThrowExceptionWithInvalidViewEngine ( )
37
47
{
@@ -48,7 +58,7 @@ public void WithViewEngineShouldThrowExceptionWithInvalidViewEngine()
48
58
}
49
59
50
60
[ Fact ]
51
- public void WithViewEngineOfTypeShouldNotThrowExceptionWithValidViewEngine ( )
61
+ public void WithViewEngineOfTypeShouldNotThrowExceptionWithValidViewEngineForGeneric ( )
52
62
{
53
63
MyViewComponent < ViewEngineComponent >
54
64
. InvokedWith ( c => c . Invoke ( new CustomViewEngine ( ) ) )
@@ -58,7 +68,17 @@ public void WithViewEngineOfTypeShouldNotThrowExceptionWithValidViewEngine()
58
68
}
59
69
60
70
[ Fact ]
61
- public void WithViewEngineOfTypeShouldThrowExceptionWithInvalidViewEngine ( )
71
+ public void WithViewEngineOfTypeShouldNotThrowExceptionWithValidViewEngine ( )
72
+ {
73
+ MyViewComponent < ViewEngineComponent >
74
+ . InvokedWith ( c => c . Invoke ( new CustomViewEngine ( ) ) )
75
+ . ShouldReturn ( )
76
+ . View ( )
77
+ . WithViewEngineOfType ( typeof ( CustomViewEngine ) ) ;
78
+ }
79
+
80
+ [ Fact ]
81
+ public void WithViewEngineOfTypeShouldThrowExceptionWithInvalidViewEngineForGeneric ( )
62
82
{
63
83
Test . AssertException < ViewViewComponentResultAssertionException > (
64
84
( ) =>
@@ -73,7 +93,22 @@ public void WithViewEngineOfTypeShouldThrowExceptionWithInvalidViewEngine()
73
93
}
74
94
75
95
[ Fact ]
76
- public void WithViewEngineOfTypeShouldNotThrowExceptionWithNullViewEngine ( )
96
+ public void WithViewEngineOfTypeShouldThrowExceptionWithInvalidViewEngine ( )
97
+ {
98
+ Test . AssertException < ViewViewComponentResultAssertionException > (
99
+ ( ) =>
100
+ {
101
+ MyViewComponent < ViewEngineComponent >
102
+ . InvokedWith ( c => c . Invoke ( new CustomViewEngine ( ) ) )
103
+ . ShouldReturn ( )
104
+ . View ( )
105
+ . WithViewEngineOfType ( typeof ( IViewEngine ) ) ;
106
+ } ,
107
+ "When invoking ViewEngineComponent expected view result ViewEngine to be of IViewEngine type, but instead received CustomViewEngine." ) ;
108
+ }
109
+
110
+ [ Fact ]
111
+ public void WithViewEngineOfTypeShouldNotThrowExceptionWithNullViewEngineForGeneric ( )
77
112
{
78
113
Test . AssertException < ViewViewComponentResultAssertionException > (
79
114
( ) =>
@@ -88,7 +123,22 @@ public void WithViewEngineOfTypeShouldNotThrowExceptionWithNullViewEngine()
88
123
}
89
124
90
125
[ Fact ]
91
- public void AndAlsoShouldWorkCorrectly ( )
126
+ public void WithViewEngineOfTypeShouldNotThrowExceptionWithNullViewEngine ( )
127
+ {
128
+ Test . AssertException < ViewViewComponentResultAssertionException > (
129
+ ( ) =>
130
+ {
131
+ MyViewComponent < ViewResultComponent >
132
+ . InvokedWith ( c => c . Invoke ( null ) )
133
+ . ShouldReturn ( )
134
+ . View ( )
135
+ . WithViewEngineOfType ( typeof ( CustomViewEngine ) ) ;
136
+ } ,
137
+ "When invoking ViewResultComponent expected view result ViewEngine to be of CustomViewEngine type, but instead received CompositeViewEngine." ) ;
138
+ }
139
+
140
+ [ Fact ]
141
+ public void AndAlsoShouldWorkCorrectlyForGeneric ( )
92
142
{
93
143
MyViewComponent < ViewResultComponent >
94
144
. InvokedWith ( c => c . Invoke ( "All" ) )
@@ -98,5 +148,17 @@ public void AndAlsoShouldWorkCorrectly()
98
148
. AndAlso ( )
99
149
. WithModelOfType < ResponseModel > ( ) ;
100
150
}
151
+
152
+ [ Fact ]
153
+ public void AndAlsoShouldWorkCorrectly ( )
154
+ {
155
+ MyViewComponent < ViewResultComponent >
156
+ . InvokedWith ( c => c . Invoke ( "All" ) )
157
+ . ShouldReturn ( )
158
+ . View ( "SomeView" )
159
+ . WithViewEngineOfType ( typeof ( CompositeViewEngine ) )
160
+ . AndAlso ( )
161
+ . WithModelOfType ( typeof ( ResponseModel ) ) ;
162
+ }
101
163
}
102
164
}
0 commit comments