diff --git a/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMap.Microsoft.DependencyInjection.Tests.csproj b/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMap.Microsoft.DependencyInjection.Tests.csproj
index db04d1a..68b34f5 100644
--- a/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMap.Microsoft.DependencyInjection.Tests.csproj
+++ b/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMap.Microsoft.DependencyInjection.Tests.csproj
@@ -16,10 +16,13 @@
+
+
+
diff --git a/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMapContainerTests.cs b/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMapContainerTests.cs
index 7740e83..53208e6 100644
--- a/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMapContainerTests.cs
+++ b/test/StructureMap.Microsoft.DependencyInjection.Tests/StructureMapContainerTests.cs
@@ -5,6 +5,7 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.DependencyInjection.Specification;
using Microsoft.Extensions.DependencyInjection.Specification.Fakes;
+using Microsoft.Extensions.Options;
using Xunit;
namespace StructureMap.Microsoft.DependencyInjection.Tests
@@ -60,6 +61,33 @@ public void CanResolveIEnumerableWithDefaultConstructor()
Assert.NotEmpty(logger.Factory.Providers);
}
+ [Fact]
+ public void CanResolveIOptionsTFromChildContainer()
+ {
+
+ ServiceCollection services = new ServiceCollection();
+
+ StructureMap.Container container = new StructureMap.Container();
+ container.Populate(services);
+
+ var childContainer = container.CreateChildContainer();
+ childContainer.Configure((a) =>
+ {
+ var childServices = new ServiceCollection();
+ childServices.AddOptions();
+ childServices.Configure((b) =>
+ {
+ b.Prop = true;
+ });
+ a.Populate(childServices);
+ });
+
+ IServiceProvider sp = childContainer.GetInstance();
+ IOptions options = sp.GetRequiredService>();
+ Assert.True(options.Value?.Prop);
+
+ }
+
private interface ILoggerProvider { }
private class TestLoggerProvider : ILoggerProvider { }
@@ -97,5 +125,10 @@ public Logger(ILoggerFactory factory)
public ILoggerFactory Factory { get; }
}
+
+ private class MyOptions
+ {
+ public bool Prop { get; internal set; }
+ }
}
}