Skip to content

Commit 8fabaf8

Browse files
committed
Add 'test/Autofac.Extras.Tests.EnterpriseLibraryConfigurator/' from commit 'c0e080f75353d02f63559e966d8ae8fec6336b53'
git-subtree-dir: test/Autofac.Extras.Tests.EnterpriseLibraryConfigurator git-subtree-mainline: d61e833 git-subtree-split: c0e080f
2 parents d61e833 + c0e080f commit 8fabaf8

File tree

7 files changed

+746
-0
lines changed

7 files changed

+746
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{0122ECB8-93C3-4020-A28D-1078E32C5DB2}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Autofac.Extras.Tests.EnterpriseLibraryConfigurator</RootNamespace>
12+
<AssemblyName>Autofac.Extras.Tests.EnterpriseLibraryConfigurator</AssemblyName>
13+
<FileAlignment>512</FileAlignment>
14+
<SignAssembly>true</SignAssembly>
15+
<AssemblyOriginatorKeyFile>..\..\..\Build\SharedKey.snk</AssemblyOriginatorKeyFile>
16+
<TargetFrameworkVersion Condition="$(TargetFrameworkVersion)==''">v4.0</TargetFrameworkVersion>
17+
<TargetFrameworkProfile Condition="$(TargetFrameworkVersion)==''">
18+
</TargetFrameworkProfile>
19+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
20+
<RestorePackages>true</RestorePackages>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
23+
<DebugSymbols>true</DebugSymbols>
24+
<DebugType>full</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Debug\</OutputPath>
27+
<DefineConstants>DEBUG;TRACE</DefineConstants>
28+
<ErrorReport>prompt</ErrorReport>
29+
<WarningLevel>4</WarningLevel>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
32+
<DebugType>pdbonly</DebugType>
33+
<Optimize>true</Optimize>
34+
<OutputPath>bin\Release\</OutputPath>
35+
<DefineConstants>TRACE</DefineConstants>
36+
<ErrorReport>prompt</ErrorReport>
37+
<WarningLevel>4</WarningLevel>
38+
</PropertyGroup>
39+
<ItemGroup>
40+
<Reference Include="Autofac, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
41+
<SpecificVersion>False</SpecificVersion>
42+
<HintPath>..\..\..\packages\Autofac.3.3.1\lib\net40\Autofac.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Microsoft.Practices.EnterpriseLibrary.Common">
45+
<HintPath>..\..\..\packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<SpecificVersion>False</SpecificVersion>
49+
<HintPath>..\..\..\packages\CommonServiceLocator.1.2\lib\portable-windows8+net40+sl5+windowsphone8\Microsoft.Practices.ServiceLocation.dll</HintPath>
50+
</Reference>
51+
<Reference Include="Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
52+
<SpecificVersion>False</SpecificVersion>
53+
<HintPath>..\..\..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
54+
</Reference>
55+
<Reference Include="Microsoft.Practices.Unity.Configuration, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
56+
<SpecificVersion>False</SpecificVersion>
57+
<HintPath>..\..\..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
58+
</Reference>
59+
<Reference Include="Microsoft.Practices.Unity.Interception, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60+
<SpecificVersion>False</SpecificVersion>
61+
<HintPath>..\..\..\packages\Unity.Interception.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Interception.dll</HintPath>
62+
</Reference>
63+
<Reference Include="Microsoft.Practices.Unity.Interception.Configuration, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<SpecificVersion>False</SpecificVersion>
65+
<HintPath>..\..\..\packages\Unity.Interception.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Interception.Configuration.dll</HintPath>
66+
</Reference>
67+
<Reference Include="nunit.framework">
68+
<HintPath>..\..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
69+
</Reference>
70+
<Reference Include="System" />
71+
<Reference Include="System.Configuration" />
72+
<Reference Include="System.Core" />
73+
<Reference Include="System.Xml.Linq" />
74+
<Reference Include="System.Data.DataSetExtensions" />
75+
<Reference Include="Microsoft.CSharp" />
76+
<Reference Include="System.Data" />
77+
<Reference Include="System.Xml" />
78+
</ItemGroup>
79+
<ItemGroup>
80+
<Compile Include="..\..\..\GlobalAssemblyInfo.cs">
81+
<Link>Properties\GlobalAssemblyInfo.cs</Link>
82+
</Compile>
83+
<Compile Include="..\..\Source\Autofac.Extras.EnterpriseLibraryConfigurator\Properties\VersionAssemblyInfo.cs">
84+
<Link>Properties\VersionAssemblyInfo.cs</Link>
85+
</Compile>
86+
<Compile Include="AutofacContainerConfiguratorFixture.cs" />
87+
<Compile Include="AutofacParameterBuilderVisitorFixture.cs" />
88+
<Compile Include="EnterpriseLibraryRegistrationExtensionsFixture.cs" />
89+
<Compile Include="Properties\AssemblyInfo.cs" />
90+
</ItemGroup>
91+
<ItemGroup>
92+
<ProjectReference Include="..\..\Source\Autofac.Extras.EnterpriseLibraryConfigurator\Autofac.Extras.EnterpriseLibraryConfigurator.csproj">
93+
<Project>{97bc9d7b-a233-4109-afb7-1f2f0c137ccf}</Project>
94+
<Name>Autofac.Extras.EnterpriseLibraryConfigurator</Name>
95+
</ProjectReference>
96+
</ItemGroup>
97+
<ItemGroup>
98+
<None Include="app.config" />
99+
<None Include="packages.config" />
100+
</ItemGroup>
101+
<ItemGroup>
102+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
103+
</ItemGroup>
104+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
105+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
106+
Other similar extension points exist, see Microsoft.Common.targets.
107+
<Target Name="BeforeBuild">
108+
</Target>
109+
<Target Name="AfterBuild">
110+
</Target>
111+
-->
112+
</Project>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Autofac;
4+
using Autofac.Extras.EnterpriseLibraryConfigurator;
5+
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
6+
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel;
7+
using NUnit.Framework;
8+
9+
namespace Autofac.Extras.Tests.EnterpriseLibraryConfigurator
10+
{
11+
[TestFixture]
12+
public class AutofacContainerConfiguratorFixture
13+
{
14+
[Test(Description = "Tries to create a configurator on a null builder.")]
15+
public void Ctor_NullBuilder()
16+
{
17+
Assert.Throws<ArgumentNullException>(() => new AutofacContainerConfigurator(null));
18+
}
19+
20+
[Test(Description = "Tries to register dependencies from a null configuration source.")]
21+
public void RegisterAll_NullConfigurationSource()
22+
{
23+
var builder = new ContainerBuilder();
24+
var configurator = new AutofacContainerConfigurator(builder);
25+
var rootProvider = new StubRegistrationProvider();
26+
Assert.Throws<ArgumentNullException>(() => configurator.RegisterAll(null, rootProvider));
27+
}
28+
29+
[Test(Description = "Tries to register dependencies using a null registration provider.")]
30+
public void RegisterAll_NullRegistrationProvider()
31+
{
32+
var builder = new ContainerBuilder();
33+
var configurator = new AutofacContainerConfigurator(builder);
34+
var configurationSource = new NullConfigurationSource();
35+
Assert.Throws<ArgumentNullException>(() => configurator.RegisterAll(configurationSource, null));
36+
}
37+
38+
[Test(Description = "Verifies that a placeholder configuration change event source is added so EntLib components that require it will find it.")]
39+
public void RegisterAll_RegistersPlaceholderConfigurationChangeEventSource()
40+
{
41+
var container = this.ExecuteRegisterAllOnValidConfigurator();
42+
Assert.IsTrue(container.IsRegistered<ConfigurationChangeEventSource>(), "A ConfigurationChangeEventSource should have been found in the container.");
43+
}
44+
45+
[Test(Description = "Verifies that the provided EntLib registrations get added to the Autofac container.")]
46+
public void RegisterAll_RegistersProvidedTypeRegistrations()
47+
{
48+
var container = this.ExecuteRegisterAllOnValidConfigurator();
49+
Assert.IsTrue(container.IsRegistered<ISampleService>(), "The provided registration was not added to the container.");
50+
}
51+
52+
private IContainer ExecuteRegisterAllOnValidConfigurator()
53+
{
54+
var builder = new ContainerBuilder();
55+
var configurator = new AutofacContainerConfigurator(builder);
56+
var configurationSource = new NullConfigurationSource();
57+
var rootProvider = new StubRegistrationProvider();
58+
configurator.RegisterAll(configurationSource, rootProvider);
59+
return builder.Build();
60+
}
61+
62+
private class StubRegistrationProvider : ITypeRegistrationsProvider
63+
{
64+
public IEnumerable<TypeRegistration> GetRegistrations(IConfigurationSource configurationSource)
65+
{
66+
yield return new TypeRegistration<ISampleService>(() => new SampleServiceImpl()) { IsDefault = true };
67+
}
68+
69+
public IEnumerable<TypeRegistration> GetUpdatedRegistrations(IConfigurationSource configurationSource)
70+
{
71+
throw new NotImplementedException();
72+
}
73+
}
74+
75+
private interface ISampleService
76+
{
77+
}
78+
79+
private class SampleServiceImpl : ISampleService
80+
{
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)