Skip to content

Commit 284c303

Browse files
committed
All unit tests now have the new MyController, MyRoutes and MyApplication classes (#133)
1 parent e8904da commit 284c303

File tree

97 files changed

+3071
-3068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+3071
-3068
lines changed

src/MyTested.AspNetCore.Mvc.Core/Internal/Application/TestApplication.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,16 @@ internal static TestConfiguration TestConfiguration
165165

166166
public static void TryInitialize()
167167
{
168-
if (!initialiazed && TestConfiguration.AutomaticStartup)
168+
lock(Sync)
169169
{
170-
startupType = TryFindDefaultStartupType();
171-
172-
if (startupType != null)
170+
if (!initialiazed && TestConfiguration.AutomaticStartup)
173171
{
174-
Initialize();
172+
startupType = TryFindDefaultStartupType();
173+
174+
if (startupType != null)
175+
{
176+
Initialize();
177+
}
175178
}
176179
}
177180
}

test/MyTested.AspNetCore.Mvc.Caching.Test/BuildersTests/DataTests/MemoryCacheBuilderTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ public class MemoryCacheBuilderTests : IDisposable
1313
{
1414
public MemoryCacheBuilderTests()
1515
{
16-
MyMvc
16+
MyApplication
1717
.IsUsingDefaultConfiguration()
1818
.WithServices(services => services.AddMemoryCache());
1919
}
2020

2121
[Fact]
2222
public void WithEntryShouldSetCorrectValues()
2323
{
24-
MyMvc
25-
.Controller<MemoryCacheController>()
24+
MyController<MemoryCacheController>
25+
.Instance()
2626
.WithMemoryCache(memoryCache => memoryCache
2727
.WithEntry("Normal", "NormalValid")
2828
.AndAlso()
@@ -36,8 +36,8 @@ public void WithEntryShouldSetCorrectValues()
3636
[Fact]
3737
public void WithCacheOptionsShouldSetCorrectValues()
3838
{
39-
MyMvc
40-
.Controller<MemoryCacheController>()
39+
MyController<MemoryCacheController>
40+
.Instance()
4141
.WithMemoryCache(memoryCache => memoryCache
4242
.WithEntry("FullEntry", "FullEntryValid", new MemoryCacheEntryOptions
4343
{
@@ -62,8 +62,8 @@ public void WithCacheOptionsShouldSetCorrectValues()
6262
[Fact]
6363
public void WithCacheBuilderShouldSetCorrectValues()
6464
{
65-
MyMvc
66-
.Controller<MemoryCacheController>()
65+
MyController<MemoryCacheController>
66+
.Instance()
6767
.WithMemoryCache(memoryCache => memoryCache
6868
.WithEntry(entry => entry
6969
.WithKey("FullEntry")
@@ -95,8 +95,8 @@ public void WithCacheBuilderWithoutKeyShouldThrowException()
9595
{
9696
Test.AssertException<InvalidOperationException>(() =>
9797
{
98-
MyMvc
99-
.Controller<MemoryCacheController>()
98+
MyController<MemoryCacheController>
99+
.Instance()
100100
.WithMemoryCache(memoryCache => memoryCache
101101
.WithEntry(entry => entry.WithValue("WithoutKey")))
102102
.Calling(c => c.FullMemoryCacheAction(From.Services<IMemoryCache>()))
@@ -109,8 +109,8 @@ public void WithCacheBuilderWithoutKeyShouldThrowException()
109109
[Fact]
110110
public void WithCacheEntriesShouldSetCorrectValues()
111111
{
112-
MyMvc
113-
.Controller<MemoryCacheController>()
112+
MyController<MemoryCacheController>
113+
.Instance()
114114
.WithMemoryCache(memoryCache => memoryCache
115115
.WithEntries(new Dictionary<object, object>
116116
{
@@ -131,7 +131,7 @@ public void WithCacheEntriesShouldSetCorrectValues()
131131

132132
public void Dispose()
133133
{
134-
MyMvc.IsUsingDefaultConfiguration();
134+
MyApplication.IsUsingDefaultConfiguration();
135135
}
136136
}
137137
}

test/MyTested.AspNetCore.Mvc.Caching.Test/BuildersTests/DataTests/MemoryCacheEntryTestBuilderTests.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ public class MemoryCacheEntryTestBuilderTests : IDisposable
1313
{
1414
public MemoryCacheEntryTestBuilderTests()
1515
{
16-
MyMvc
16+
MyApplication
1717
.IsUsingDefaultConfiguration()
1818
.WithServices(services => services.AddMemoryCache());
1919
}
2020

2121
[Fact]
2222
public void WithValidShouldNotThrowExceptionWithCorrectValue()
2323
{
24-
MyMvc
25-
.Controller<MvcController>()
24+
MyController<MvcController>
25+
.Instance()
2626
.Calling(c => c.AddMemoryCacheAction())
2727
.ShouldHave()
2828
.MemoryCache(memoryCache => memoryCache
@@ -40,8 +40,8 @@ public void WithValidShouldThrowExceptionWithInvorrectValue()
4040
Test.AssertException<DataProviderAssertionException>(
4141
() =>
4242
{
43-
MyMvc
44-
.Controller<MvcController>()
43+
MyController<MvcController>
44+
.Instance()
4545
.Calling(c => c.AddMemoryCacheAction())
4646
.ShouldHave()
4747
.MemoryCache(memoryCache => memoryCache
@@ -58,8 +58,8 @@ public void WithValidShouldThrowExceptionWithInvorrectValue()
5858
[Fact]
5959
public void WithAbsoluteExpirationShouldNotThrowExceptionWithCorrectValue()
6060
{
61-
MyMvc
62-
.Controller<MvcController>()
61+
MyController<MvcController>
62+
.Instance()
6363
.Calling(c => c.AddMemoryCacheAction())
6464
.ShouldHave()
6565
.MemoryCache(memoryCache => memoryCache
@@ -77,8 +77,8 @@ public void WithAbsoluteExpirationShouldThrowExceptionWithInvorrectValue()
7777
Test.AssertException<DataProviderAssertionException>(
7878
() =>
7979
{
80-
MyMvc
81-
.Controller<MvcController>()
80+
MyController<MvcController>
81+
.Instance()
8282
.Calling(c => c.AddMemoryCacheAction())
8383
.ShouldHave()
8484
.MemoryCache(memoryCache => memoryCache
@@ -95,8 +95,8 @@ public void WithAbsoluteExpirationShouldThrowExceptionWithInvorrectValue()
9595
[Fact]
9696
public void WithAbsoluteExpirationRelativeToNowShouldNotThrowExceptionWithCorrectValue()
9797
{
98-
MyMvc
99-
.Controller<MvcController>()
98+
MyController<MvcController>
99+
.Instance()
100100
.Calling(c => c.AddMemoryCacheAction())
101101
.ShouldHave()
102102
.MemoryCache(memoryCache => memoryCache
@@ -114,8 +114,8 @@ public void WithAbsoluteExpirationRelativeToNowShouldThrowExceptionWithInvorrect
114114
Test.AssertException<DataProviderAssertionException>(
115115
() =>
116116
{
117-
MyMvc
118-
.Controller<MvcController>()
117+
MyController<MvcController>
118+
.Instance()
119119
.Calling(c => c.AddMemoryCacheAction())
120120
.ShouldHave()
121121
.MemoryCache(memoryCache => memoryCache
@@ -132,8 +132,8 @@ public void WithAbsoluteExpirationRelativeToNowShouldThrowExceptionWithInvorrect
132132
[Fact]
133133
public void WithPriorityShouldNotThrowExceptionWithCorrectValue()
134134
{
135-
MyMvc
136-
.Controller<MvcController>()
135+
MyController<MvcController>
136+
.Instance()
137137
.Calling(c => c.AddMemoryCacheAction())
138138
.ShouldHave()
139139
.MemoryCache(memoryCache => memoryCache
@@ -151,8 +151,8 @@ public void WithPriorityShouldThrowExceptionWithInvorrectValue()
151151
Test.AssertException<DataProviderAssertionException>(
152152
() =>
153153
{
154-
MyMvc
155-
.Controller<MvcController>()
154+
MyController<MvcController>
155+
.Instance()
156156
.Calling(c => c.AddMemoryCacheAction())
157157
.ShouldHave()
158158
.MemoryCache(memoryCache => memoryCache
@@ -169,8 +169,8 @@ public void WithPriorityShouldThrowExceptionWithInvorrectValue()
169169
[Fact]
170170
public void WithSlidingExpirationShouldNotThrowExceptionWithCorrectValue()
171171
{
172-
MyMvc
173-
.Controller<MvcController>()
172+
MyController<MvcController>
173+
.Instance()
174174
.Calling(c => c.AddMemoryCacheAction())
175175
.ShouldHave()
176176
.MemoryCache(memoryCache => memoryCache
@@ -188,8 +188,8 @@ public void WithSlidingExpirationShouldThrowExceptionWithInvorrectValue()
188188
Test.AssertException<DataProviderAssertionException>(
189189
() =>
190190
{
191-
MyMvc
192-
.Controller<MvcController>()
191+
MyController<MvcController>
192+
.Instance()
193193
.Calling(c => c.AddMemoryCacheAction())
194194
.ShouldHave()
195195
.MemoryCache(memoryCache => memoryCache
@@ -206,7 +206,7 @@ public void WithSlidingExpirationShouldThrowExceptionWithInvorrectValue()
206206
[Fact]
207207
public void WithNoMockedMemoryCacheSomeMethodsShouldThrowException()
208208
{
209-
MyMvc
209+
MyApplication
210210
.IsUsingDefaultConfiguration()
211211
.WithServices(services =>
212212
{
@@ -216,8 +216,8 @@ public void WithNoMockedMemoryCacheSomeMethodsShouldThrowException()
216216
Test.AssertException<InvalidOperationException>(
217217
() =>
218218
{
219-
MyMvc
220-
.Controller<MvcController>()
219+
MyController<MvcController>
220+
.Instance()
221221
.Calling(c => c.AddMemoryCacheAction())
222222
.ShouldHave()
223223
.MemoryCache(memoryCache => memoryCache
@@ -230,12 +230,12 @@ public void WithNoMockedMemoryCacheSomeMethodsShouldThrowException()
230230
},
231231
"This test requires the registered IMemoryCache service to implement IMockedMemoryCache.");
232232

233-
MyMvc.IsUsingDefaultConfiguration();
233+
MyApplication.IsUsingDefaultConfiguration();
234234
}
235235

236236
public void Dispose()
237237
{
238-
MyMvc.IsUsingDefaultConfiguration();
238+
MyApplication.IsUsingDefaultConfiguration();
239239
}
240240
}
241241
}

0 commit comments

Comments
 (0)