Skip to content

Commit 3ca305b

Browse files
committed
Made all services required (closes #161)
1 parent 6ed00ea commit 3ca305b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/MyTested.AspNetCore.Mvc.Caching/HttpTestContextCachingExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public static class HttpTestContextCachingExtensions
1010
{
1111
public static IMemoryCache GetMemoryCache(this HttpTestContext testContext)
12-
=> testContext.HttpContext.RequestServices.GetService<IMemoryCache>();
12+
=> testContext.HttpContext.RequestServices.GetRequiredService<IMemoryCache>();
1313

1414
internal static IMockedMemoryCache GetMockedMemoryCache(this HttpTestContext testContext)
1515
=> testContext.GetMemoryCache().AsMockedMemoryCache();

src/MyTested.AspNetCore.Mvc.Core/Builders/Controllers/ControllerBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public IControllerTestBuilder ShouldHave()
101101

102102
private void ValidateControllerType()
103103
{
104-
var validControllers = this.Services.GetService<IValidControllersCache>();
104+
var validControllers = this.Services.GetRequiredService<IValidControllersCache>();
105105
var controllerType = typeof(TController);
106106
if (!validControllers.IsValid(typeof(TController)))
107107
{

src/MyTested.AspNetCore.Mvc.Core/Builders/Controllers/ControllerServiceBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public IAndControllerBuilder<TController> WithServiceSetupFor<TService>(Action<T
2020
CommonValidator.CheckForNullReference(scopedServiceSetup, nameof(scopedServiceSetup));
2121
ServiceValidator.ValidateScopedServiceLifetime<TService>(nameof(WithServiceSetupFor));
2222

23-
scopedServiceSetup(this.HttpContext.RequestServices.GetService<TService>());
23+
scopedServiceSetup(this.HttpContext.RequestServices.GetRequiredService<TService>());
2424

2525
return this;
2626
}

0 commit comments

Comments
 (0)