Skip to content

Commit 517d129

Browse files
authored
Merge pull request #396 Removed Language Specific Dependency On Certain Tests
Removed Language Specific Dependency On Certain Tests
2 parents 948cba8 + 0fbc23c commit 517d129

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

test/MyTested.AspNetCore.Mvc.Abstractions.Test/ServicesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void IsUsingWithStartUpClassShouldThrowExceptionWithServiceProviderWhenTe
174174

175175
TestServiceProvider.GetService<IInjectedService>();
176176
},
177-
"Testing services could not be resolved. If your ConfigureServices method returns an IServiceProvider, you should either change it to return 'void' or manually register the required testing services by calling one of the provided IServiceCollection extension methods in the 'MyTested.AspNetCore.Mvc' namespace.");
177+
"Testing services could not be resolved. If your ConfigureServices method returns an IServiceProvider, you should either change it to return 'void' or manually register the required testing services by calling one of the provided IServiceCollection extension methods in the 'MyTested.AspNetCore.Mvc' namespace. An easy way to do the second option is to add a TestStartup class at the root of your test project and invoke the extension methods there.");
178178

179179
MyApplication.StartsFrom<DefaultStartup>();
180180
}

test/MyTested.AspNetCore.Mvc.Abstractions.Test/UtilitiesTests/ReflectionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ public void AreDeeplyEqualShouldReportCorrectlyWithPrimitiveAndStructTypes()
10251025
Assert.False(Reflection.AreDeeplyEqual(1, "1", out result));
10261026
Assert.Equal("Expected a value of Int32 type, but in fact it was String", result.ToString());
10271027
Assert.False(Reflection.AreDeeplyEqual(new DateTime(2015, 10, 19), new DateTime(2015, 10, 20), out result));
1028-
Assert.Equal("Difference occurs at 'DateTime.== (Equality Operator)'. Expected a value of '10/19/2015 12:00:00 AM', but in fact it was '10/20/2015 12:00:00 AM'", result.ToString());
1028+
Assert.Equal($"Difference occurs at 'DateTime.== (Equality Operator)'. Expected a value of '{new DateTime(2015, 10, 19)}', but in fact it was '{new DateTime(2015, 10, 20)}'", result.ToString());
10291029
}
10301030

10311031
[Fact]

test/MyTested.AspNetCore.Mvc.Caching.Test/BuildersTests/ActionsTests/ShouldHaveTests/ShouldHaveMemoryCacheTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsAndIncor
268268
[Fact]
269269
public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsWithInvalidAbsoluteExpiration()
270270
{
271-
var invalidExpirationDate = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
271+
var invalidExpirationDate = new DateTimeOffset(new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc));
272+
var actualExpirationDate = new DateTimeOffset(new DateTime(2016, 1, 1, 1, 1, 1, DateTimeKind.Utc));
272273

273274
Test.AssertException<DataProviderAssertionException>(
274275
() =>
@@ -280,7 +281,7 @@ public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsWithInva
280281
.MemoryCache(cache => cache
281282
.ContainingEntry("test", "value", new MemoryCacheEntryOptions
282283
{
283-
AbsoluteExpiration = new DateTimeOffset(invalidExpirationDate),
284+
AbsoluteExpiration = invalidExpirationDate,
284285
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1),
285286
Priority = CacheItemPriority.High,
286287
SlidingExpiration = TimeSpan.FromMinutes(5)
@@ -289,7 +290,7 @@ public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsWithInva
289290
.ShouldReturn()
290291
.Ok();
291292
},
292-
"When calling AddMemoryCacheAction action in MvcController expected memory cache to have entry with the given options, but in fact they were different. Difference occurs at 'MemoryCacheEntryOptions.AbsoluteExpiration.== (Equality Operator)'. Expected a value of '1/1/2017 1:01:01 AM +00:00', but in fact it was '1/1/2016 1:01:01 AM +00:00'.");
293+
$"When calling AddMemoryCacheAction action in MvcController expected memory cache to have entry with the given options, but in fact they were different. Difference occurs at 'MemoryCacheEntryOptions.AbsoluteExpiration.== (Equality Operator)'. Expected a value of '{invalidExpirationDate}', but in fact it was '{actualExpirationDate}'.");
293294
}
294295

295296
[Fact]

test/MyTested.AspNetCore.Mvc.Caching.Test/BuildersTests/InvocationsTests/ShouldHaveTests/ShouldHaveMemoryCacheTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsAndIncor
242242
[Fact]
243243
public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsWithInvalidAbsoluteExpiration()
244244
{
245-
var invalidExpirationDate = new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc);
245+
var invalidExpirationDate = new DateTimeOffset(new DateTime(2017, 1, 1, 1, 1, 1, DateTimeKind.Utc));
246+
var actualExpirationDate = new DateTimeOffset(new DateTime(2016, 1, 1, 1, 1, 1, DateTimeKind.Utc));
246247

247248
Test.AssertException<DataProviderAssertionException>(
248249
() =>
@@ -253,7 +254,7 @@ public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsWithInva
253254
.MemoryCache(cache => cache
254255
.ContainingEntry("test", "value", new MemoryCacheEntryOptions
255256
{
256-
AbsoluteExpiration = new DateTimeOffset(invalidExpirationDate),
257+
AbsoluteExpiration = invalidExpirationDate,
257258
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1),
258259
Priority = CacheItemPriority.High,
259260
SlidingExpiration = TimeSpan.FromMinutes(5)
@@ -262,7 +263,7 @@ public void MemoryCacheWithBuilderShouldThrowWithMemoryCacheEntryOptionsWithInva
262263
.ShouldReturn()
263264
.View();
264265
},
265-
"When invoking MemoryCacheValuesComponent expected memory cache to have entry with the given options, but in fact they were different. Difference occurs at 'MemoryCacheEntryOptions.AbsoluteExpiration.== (Equality Operator)'. Expected a value of '1/1/2017 1:01:01 AM +00:00', but in fact it was '1/1/2016 1:01:01 AM +00:00'.");
266+
$"When invoking MemoryCacheValuesComponent expected memory cache to have entry with the given options, but in fact they were different. Difference occurs at 'MemoryCacheEntryOptions.AbsoluteExpiration.== (Equality Operator)'. Expected a value of '{invalidExpirationDate}', but in fact it was '{actualExpirationDate}'.");
266267
}
267268

268269
[Fact]

test/MyTested.AspNetCore.Mvc.NewtonsoftJson.Test/BuildersTests/ActionResultsTests/JsonTests/JsonSerializerTestBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void WithCultureShouldThrowExceptionWithIncorrectValue()
109109
.WithJsonSerializerSettings(s =>
110110
s.WithCulture(CultureInfo.GetCultureInfo("en-US"))));
111111
},
112-
"When calling JsonWithSettingsAction action in MvcController expected JSON result serializer settings to have 'English (United States)' culture, but in fact found 'Unknown language'.");
112+
$"When calling JsonWithSettingsAction action in MvcController expected JSON result serializer settings to have '{CultureInfo.GetCultureInfo("en-US").DisplayName}' culture, but in fact found '{CultureInfo.InvariantCulture.DisplayName}'.");
113113
}
114114

115115
[Fact]

0 commit comments

Comments
 (0)