Skip to content

Commit 7427dcd

Browse files
committed
Changed from OptionsManager<> to the new UnnamedOptionsManager<>
1 parent 7b09040 commit 7427dcd

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

src/MyTested.AspNetCore.Mvc.Abstractions/Internal/Server/TestWebServer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ private static IWebHostEnvironment PrepareEnvironment()
2020
ApplicationName = ApplicationName,
2121
EnvironmentName = ServerTestConfiguration.General.EnvironmentName,
2222
ContentRootPath = AppContext.BaseDirectory,
23-
WebRootFileProvider = new NullFileProvider()
23+
WebRootFileProvider = new NullFileProvider(),
24+
ContentRootFileProvider = new NullFileProvider()
2425
};
2526

2627
internal static void ResetConfigurationAndAssemblies()

src/MyTested.AspNetCore.Mvc.Abstractions/Internal/TestFramework.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
public static class TestFramework
88
{
99
public const string TestFrameworkName = "MyTested.AspNetCore.Mvc";
10-
public const string ReleaseDate = "2022-03-11";
10+
public const string ReleaseDate = "2022-12-28";
1111
public const string VersionPrefix = "6.0";
1212

1313
internal static void EnsureCorrectVersion(DependencyContext dependencyContext)

src/MyTested.AspNetCore.Mvc.EntityFrameworkCore/ServiceCollectionEntityFrameworkCoreExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.EntityFrameworkCore;
99
using Microsoft.EntityFrameworkCore.Infrastructure;
1010
using Microsoft.Extensions.DependencyInjection;
11+
using Microsoft.Extensions.DependencyInjection.Extensions;
1112
using Utilities.Extensions;
1213

1314
/// <summary>
@@ -62,7 +63,7 @@ public static IServiceCollection ReplaceDbContext(this IServiceCollection servic
6263
.MakeGenericMethod(existingDbContextService.ServiceType, existingDbContextService.ImplementationType)
6364
.Invoke(null, new object[] { serviceCollection });
6465
});
65-
66+
6667
TestServiceProvider.SaveServiceLifetime(BaseDbContextType, ServiceLifetime.Scoped);
6768

6869
return serviceCollection;
@@ -75,7 +76,7 @@ private static void AddScopedDatabase<TDbContextService, TDbContextImplementatio
7576

7677
if (typeof(TDbContextService) != typeof(TDbContextImplementation))
7778
{
78-
serviceCollection.AddScoped(s => s.GetRequiredService<TDbContextService>() as TDbContextImplementation);
79+
serviceCollection.TryAddScoped(s => s.GetRequiredService<TDbContextService>() as TDbContextImplementation);
7980

8081
TestServiceProvider.SaveServiceLifetime<TDbContextImplementation>(ServiceLifetime.Scoped);
8182
}

src/MyTested.AspNetCore.Mvc.Options/Plugins/OptionsTestPlugin.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66

77
public class OptionsTestPlugin : IServiceRegistrationPlugin
88
{
9+
private const string DefaultOptionsImplementationTypeFullName = "Microsoft.Extensions.Options.UnnamedOptionsManager`1";
10+
911
private readonly Type defaultOptionsServiceType = typeof(IOptions<>);
10-
private readonly Type defaultOptionsImplementationType = typeof(OptionsManager<>);
11-
12+
1213
public Func<ServiceDescriptor, bool> ServiceSelectorPredicate
1314
=> serviceDescriptor =>
1415
serviceDescriptor.ServiceType == this.defaultOptionsServiceType &&
15-
serviceDescriptor.ImplementationType == this.defaultOptionsImplementationType;
16+
serviceDescriptor.ImplementationType?.FullName == DefaultOptionsImplementationTypeFullName;
1617

17-
public Action<IServiceCollection> ServiceRegistrationDelegate
18+
public Action<IServiceCollection> ServiceRegistrationDelegate
1819
=> serviceCollection => serviceCollection.ReplaceOptions();
1920
}
2021
}

test/MyTested.AspNetCore.Mvc.ViewData.Test/PluginsTests/ViewDataTestPluginTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ShouldInvokeMethodOfTypeVoidWithValidServiceCollection()
3333

3434
testPlugin.DefaultServiceRegistrationDelegate(serviceCollection);
3535

36-
Assert.True(serviceCollection.Count == 160);
36+
Assert.True(serviceCollection.Count == 165);
3737
}
3838
}
3939
}

0 commit comments

Comments
 (0)