--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Autofac;
+using Autofac.Extensions.DependencyInjection;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class AutofacDependencyInjectionSpecificationTests: DependencyInjectionSpecificationTests
+ {
+ protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
+ {
+ var builder = new ContainerBuilder();
+ builder.Populate(serviceCollection);
+ return new AutofacServiceProvider(builder.Build());
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using DryIoc;
+using DryIoc.Microsoft.DependencyInjection;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class DryIocDependencyInjectionSpecificationTests: DependencyInjectionSpecificationTests
+ {
+ protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
+ {
+ return new Container()
+ .WithDependencyInjectionAdapter(serviceCollection)
+ .BuildServiceProvider();
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Grace.DependencyInjection;
+using Grace.DependencyInjection.Extensions;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class GraceDependencyInjectionSpecificationTests: SkippableDependencyInjectionSpecificationTests
+ {
+ public override string[] SkippedTests => new[]
+ {
+ "ResolvesMixedOpenClosedGenericsAsEnumerable",
+ "TypeActivatorWorksWithCtorWithOptionalArgs_WithStructDefaults"
+ };
+
+ protected override IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection)
+ {
+ return new DependencyInjectionContainer().Populate(serviceCollection);
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class LamarDependencyInjectionSpecificationTests : SkippableDependencyInjectionSpecificationTests
+ {
+ public override string[] SkippedTests => new[]
+ {
+ "DisposesInReverseOrderOfCreation",
+ "ResolvesMixedOpenClosedGenericsAsEnumerable"
+ };
+
+ protected override IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection)
+ {
+ return Lamar.Container.BuildAsync(serviceCollection).Result;
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Autofac;
+using Autofac.Extensions.DependencyInjection;
+using LightInject.Microsoft.DependencyInjection;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class LightInjectDependencyInjectionSpecificationTests: DependencyInjectionSpecificationTests
+ {
+ protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
+ {
+ var builder = new ContainerBuilder();
+ builder.Populate(serviceCollection);
+ return serviceCollection.CreateLightInjectServiceProvider();
+ }
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFrameworks>$(DefaultNetCoreTargetFramework);net472</TargetFrameworks>
+ <RootNamespace>Microsoft.Extensions.DependencyInjection</RootNamespace>
+ <SignAssembly>false</SignAssembly>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json" />
+
+ <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
+ <Reference Include="Microsoft.Extensions.DependencyInjection.Specification.Tests" />
+ <Reference Include="Microsoft.Extensions.DependencyInjection" />
+
+ <Reference Include="Autofac.Extensions.DependencyInjection" />
+ <Reference Include="DryIoc.Microsoft.DependencyInjection" />
+ <Reference Include="Lamar.Microsoft.DependencyInjection" />
+ <Reference Include="LightInject.Microsoft.DependencyInjection" />
+ <Reference Include="StructureMap.Microsoft.DependencyInjection" />
+ <Reference Include="Grace.DependencyInjection.Extensions" />
+ <Reference Include="Stashbox.Extensions.Dependencyinjection" />
+ <Reference Include="Unity.Microsoft.DependencyInjection" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
+ </ItemGroup>
+
+</Project>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+using System.Linq;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public abstract class SkippableDependencyInjectionSpecificationTests: DependencyInjectionSpecificationTests
+ {
+ public abstract string[] SkippedTests { get; }
+
+
+ protected sealed override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
+ {
+ foreach (var stackFrame in new StackTrace(1).GetFrames().Take(2))
+ {
+ if (SkippedTests.Contains(stackFrame.GetMethod().Name))
+ {
+ // We skip tests by returning MEDI service provider that we know passes the test
+ return serviceCollection.BuildServiceProvider();
+ }
+ }
+
+ return CreateServiceProviderImpl(serviceCollection);
+ }
+
+ protected abstract IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection);
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class StashBoxDependencyInjectionSpecificationTests: DependencyInjectionSpecificationTests
+ {
+ protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
+ {
+ return serviceCollection.UseStashbox();
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using StructureMap;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class StructureMapDependencyInjectionSpecificationTests: SkippableDependencyInjectionSpecificationTests
+ {
+ public override string[] SkippedTests => new[]
+ {
+ "DisposesInReverseOrderOfCreation",
+ "ResolvesMixedOpenClosedGenericsAsEnumerable"
+ };
+
+ protected override IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection)
+ {
+ var container = new Container();
+ container.Configure(config =>
+ {
+ config.Populate(serviceCollection);
+ });
+
+ return container.GetInstance<IServiceProvider>();
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace Microsoft.Extensions.DependencyInjection.Specification
+{
+ public class UnityDependencyInjectionSpecificationTests: SkippableDependencyInjectionSpecificationTests
+ {
+ public override string[] SkippedTests => new[]
+ {
+ "SingletonServiceCanBeResolvedFromScope"
+ };
+
+ protected override IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection)
+ {
+ return Unity.Microsoft.DependencyInjection.ServiceProviderExtensions.BuildServiceProvider(serviceCollection);
+ }
+ }
+}