diff --git a/src/Microsoft.AspNetCore.Mvc.Testing/MvcWebApplicationBuilder.cs b/src/Microsoft.AspNetCore.Mvc.Testing/MvcWebApplicationBuilder.cs
index a2837bc9c4..56e4b45dce 100644
--- a/src/Microsoft.AspNetCore.Mvc.Testing/MvcWebApplicationBuilder.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Testing/MvcWebApplicationBuilder.cs
@@ -93,6 +93,16 @@ namespace Microsoft.AspNetCore.Mvc.Testing
/// An instance of this
public MvcWebApplicationBuilder UseRequestCulture(string culture, string uiCulture)
{
+ if (culture == null)
+ {
+ throw new ArgumentNullException(nameof(culture));
+ }
+
+ if (uiCulture == null)
+ {
+ throw new ArgumentNullException(nameof(uiCulture));
+ }
+
ConfigureBeforeStartup(services =>
{
services.TryAddSingleton(new TestCulture
@@ -116,6 +126,16 @@ namespace Microsoft.AspNetCore.Mvc.Testing
/// An instance of this
public MvcWebApplicationBuilder UseStartupCulture(string culture, string uiCulture)
{
+ if (culture == null)
+ {
+ throw new ArgumentNullException(nameof(culture));
+ }
+
+ if (uiCulture == null)
+ {
+ throw new ArgumentNullException(nameof(uiCulture));
+ }
+
_systemCulture = new TestCulture { Culture = culture, UICulture = uiCulture };
return this;
}
@@ -130,6 +150,11 @@ namespace Microsoft.AspNetCore.Mvc.Testing
string solutionRelativePath,
string solutionName = "*.sln")
{
+ if (solutionRelativePath == null)
+ {
+ throw new ArgumentNullException(nameof(solutionRelativePath));
+ }
+
var applicationBasePath = AppContext.BaseDirectory;
var directoryInfo = new DirectoryInfo(applicationBasePath);
@@ -160,6 +185,11 @@ namespace Microsoft.AspNetCore.Mvc.Testing
.UseContentRoot(ContentRoot)
.ConfigureServices(InitializeServices);
+ if (_systemCulture == null)
+ {
+ return new TestServer(builder);
+ }
+
var originalCulture = CultureInfo.CurrentCulture;
var originalUICulture = CultureInfo.CurrentUICulture;
try