Merge commit '6ccc72a9df472b2e1efd10d0c3493d580a9992ca' into di-external
authorMaryam Ariyan <maryam.ariyan@microsoft.com>
Wed, 3 Jun 2020 15:57:44 +0000 (08:57 -0700)
committerMaryam Ariyan <maryam.ariyan@microsoft.com>
Wed, 3 Jun 2020 15:57:44 +0000 (08:57 -0700)
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Autofac.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/DryIoc.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Grace.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Lamar.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/LightInject.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/SkippableDependencyInjectionSpecificationTests.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StructureMap.cs [new file with mode: 0644]
src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Unity.cs [new file with mode: 0644]

diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Autofac.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Autofac.cs
new file mode 100644 (file)
index 0000000..68fc0f2
--- /dev/null
@@ -0,0 +1,20 @@
+// 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());
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/DryIoc.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/DryIoc.cs
new file mode 100644 (file)
index 0000000..ca62382
--- /dev/null
@@ -0,0 +1,20 @@
+// 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();
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Grace.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Grace.cs
new file mode 100644 (file)
index 0000000..5cfe355
--- /dev/null
@@ -0,0 +1,24 @@
+// 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);
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Lamar.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Lamar.cs
new file mode 100644 (file)
index 0000000..7e591e1
--- /dev/null
@@ -0,0 +1,22 @@
+// 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;
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/LightInject.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/LightInject.cs
new file mode 100644 (file)
index 0000000..65ab5a6
--- /dev/null
@@ -0,0 +1,21 @@
+// 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();
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj
new file mode 100644 (file)
index 0000000..d6b2f1e
--- /dev/null
@@ -0,0 +1,30 @@
+<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>
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/SkippableDependencyInjectionSpecificationTests.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/SkippableDependencyInjectionSpecificationTests.cs
new file mode 100644 (file)
index 0000000..321493b
--- /dev/null
@@ -0,0 +1,32 @@
+// 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);
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs
new file mode 100644 (file)
index 0000000..b9f469a
--- /dev/null
@@ -0,0 +1,16 @@
+// 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();
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StructureMap.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StructureMap.cs
new file mode 100644 (file)
index 0000000..66803d3
--- /dev/null
@@ -0,0 +1,29 @@
+// 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>();
+        }
+    }
+}
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Unity.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Unity.cs
new file mode 100644 (file)
index 0000000..eb101bc
--- /dev/null
@@ -0,0 +1,21 @@
+// 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);
+        }
+    }
+}