Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added tests verifying inability to use multiple assemblies for overrides

  • Loading branch information...
commit bd94ea5d727db85475a698aaaf6f6859aefa3c96 1 parent 3dd538a
@jagregory authored
Showing with 185 additions and 12 deletions.
  1. +4 −0 src/FluentNHibernate.Specs.ExternalFixtures/Component.cs
  2. +4 −4 src/{FluentNHibernate.Specs/Automapping/Fixtures → FluentNHibernate.Specs.ExternalFixtures}/Entity.cs
  3. +66 −0 src/FluentNHibernate.Specs.ExternalFixtures/FluentNHibernate.Specs.ExternalFixtures.csproj
  4. +13 −0 src/FluentNHibernate.Specs.ExternalFixtures/Overrides/EntityBatchSizeOverride.cs
  5. +36 −0 src/FluentNHibernate.Specs.ExternalFixtures/Properties/AssemblyInfo.cs
  6. +1 −0  src/FluentNHibernate.Specs/Automapping/AutoPersistenceModelSpecs.Conventions.cs
  7. +1 −0  src/FluentNHibernate.Specs/Automapping/AutoPersistenceModelSpecs.cs
  8. +1 −0  src/FluentNHibernate.Specs/Automapping/AutomappingSpecs.Components.cs
  9. +0 −4 src/FluentNHibernate.Specs/Automapping/Fixtures/Component.cs
  10. +1 −0  src/FluentNHibernate.Specs/Automapping/Fixtures/DictionaryEntity.cs
  11. +14 −0 src/FluentNHibernate.Specs/Automapping/Fixtures/Overrides/EntityTableOverride.cs
  12. +1 −0  src/FluentNHibernate.Specs/Automapping/Fixtures/ReadOnlyEnumerableEntity.cs
  13. +25 −2 src/FluentNHibernate.Specs/Automapping/OverrideSpecs.cs
  14. +1 −0  src/FluentNHibernate.Specs/Diagnostics/Registration_diagnostics_specs.cs
  15. +5 −2 src/FluentNHibernate.Specs/FluentNHibernate.Specs.csproj
  16. +12 −0 src/FluentNHibernate.sln
View
4 src/FluentNHibernate.Specs.ExternalFixtures/Component.cs
@@ -0,0 +1,4 @@
+namespace FluentNHibernate.Specs.ExternalFixtures
+{
+ public class Component {}
+}
View
8 ...nate.Specs/Automapping/Fixtures/Entity.cs → ...ibernate.Specs.ExternalFixtures/Entity.cs
@@ -1,8 +1,8 @@
using System.Collections.Generic;
-namespace FluentNHibernate.Specs.Automapping.Fixtures
+namespace FluentNHibernate.Specs.ExternalFixtures
{
- class Entity
+ public class Entity
{
EntityChild readOnlyChild;
@@ -13,7 +13,7 @@ class Entity
public IList<EntityChild> Children { get; set; }
public Component Component { get; set; }
- internal enum TestEnum {}
+ public enum TestEnum {}
public EntityChild ReadOnlyChild
{
@@ -21,7 +21,7 @@ public EntityChild ReadOnlyChild
}
}
- class EntityChild
+ public class EntityChild
{}
public abstract class A_Child : B_Parent
View
66 src/FluentNHibernate.Specs.ExternalFixtures/FluentNHibernate.Specs.ExternalFixtures.csproj
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{28BF853D-5B20-4091-A059-1CB0A028F981}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>FluentNHibernate.Specs.ExternalFixtures</RootNamespace>
+ <AssemblyName>FluentNHibernate.Specs.ExternalFixtures</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="NHibernate">
+ <HintPath>..\..\tools\NHibernate\NHibernate.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Component.cs" />
+ <Compile Include="Entity.cs" />
+ <Compile Include="Overrides\EntityBatchSizeOverride.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\FluentNHibernate\FluentNHibernate.csproj">
+ <Project>{529145D5-6CC3-4016-89B5-826563024AF1}</Project>
+ <Name>FluentNHibernate</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
13 src/FluentNHibernate.Specs.ExternalFixtures/Overrides/EntityBatchSizeOverride.cs
@@ -0,0 +1,13 @@
+using FluentNHibernate.Automapping;
+using FluentNHibernate.Automapping.Alterations;
+
+namespace FluentNHibernate.Specs.ExternalFixtures.Overrides
+{
+ public class EntityBatchSizeOverride : IAutoMappingOverride<Entity>
+ {
+ public void Override(AutoMapping<Entity> mapping)
+ {
+ mapping.BatchSize(1234);
+ }
+ }
+}
View
36 src/FluentNHibernate.Specs.ExternalFixtures/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FluentNHibernate.Specs.ExternalFixtures")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("FluentNHibernate.Specs.ExternalFixtures")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("791590fa-5db6-4e34-8a96-7a4ed51fe714")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
1  src/FluentNHibernate.Specs/Automapping/AutoPersistenceModelSpecs.Conventions.cs
@@ -4,6 +4,7 @@
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using FluentNHibernate.Specs.Automapping.Fixtures;
+using FluentNHibernate.Specs.ExternalFixtures;
using Machine.Specifications;
namespace FluentNHibernate.Specs.Automapping
View
1  src/FluentNHibernate.Specs/Automapping/AutoPersistenceModelSpecs.cs
@@ -8,6 +8,7 @@
using FluentNHibernate.MappingModel;
using FluentNHibernate.MappingModel.ClassBased;
using FluentNHibernate.Specs.Automapping.Fixtures;
+using FluentNHibernate.Specs.ExternalFixtures;
using Machine.Specifications;
namespace FluentNHibernate.Specs.Automapping
View
1  src/FluentNHibernate.Specs/Automapping/AutomappingSpecs.Components.cs
@@ -4,6 +4,7 @@
using FluentNHibernate.Automapping;
using FluentNHibernate.MappingModel.ClassBased;
using FluentNHibernate.Specs.Automapping.Fixtures;
+using FluentNHibernate.Specs.ExternalFixtures;
using FluentNHibernate.Utils;
using Machine.Specifications;
View
4 src/FluentNHibernate.Specs/Automapping/Fixtures/Component.cs
@@ -1,4 +0,0 @@
-namespace FluentNHibernate.Specs.Automapping.Fixtures
-{
- public class Component {}
-}
View
1  src/FluentNHibernate.Specs/Automapping/Fixtures/DictionaryEntity.cs
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
+using FluentNHibernate.Specs.ExternalFixtures;
namespace FluentNHibernate.Specs.Automapping.Fixtures
{
View
14 src/FluentNHibernate.Specs/Automapping/Fixtures/Overrides/EntityTableOverride.cs
@@ -0,0 +1,14 @@
+using FluentNHibernate.Automapping;
+using FluentNHibernate.Automapping.Alterations;
+using FluentNHibernate.Specs.ExternalFixtures;
+
+namespace FluentNHibernate.Specs.Automapping.Fixtures.Overrides
+{
+ public class EntityTableOverride : IAutoMappingOverride<Entity>
+ {
+ public void Override(AutoMapping<Entity> mapping)
+ {
+ mapping.Table("OverriddenTableName");
+ }
+ }
+}
View
1  src/FluentNHibernate.Specs/Automapping/Fixtures/ReadOnlyEnumerableEntity.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using FluentNHibernate.Specs.ExternalFixtures;
namespace FluentNHibernate.Specs.Automapping.Fixtures
{
View
27 src/FluentNHibernate.Specs/Automapping/OverrideSpecs.cs
@@ -1,9 +1,11 @@
using System.Linq;
using FluentNHibernate.Automapping;
-using FluentNHibernate.Mapping;
-using FluentNHibernate.MappingModel;
+using FluentNHibernate.Automapping.Alterations;
using FluentNHibernate.MappingModel.ClassBased;
using FluentNHibernate.Specs.Automapping.Fixtures;
+using FluentNHibernate.Specs.Automapping.Fixtures.Overrides;
+using FluentNHibernate.Specs.ExternalFixtures;
+using FluentNHibernate.Specs.ExternalFixtures.Overrides;
using Machine.Specifications;
namespace FluentNHibernate.Specs.Automapping
@@ -53,4 +55,25 @@ public class when_using_an_automapping_override_to_specify_a_discriminator
static AutoPersistenceModel model;
static ClassMapping mapping;
}
+
+ [Subject(typeof(IAutoMappingOverride<>))]
+ public class when_using_multiple_overrides_from_different_assemblies
+ {
+ Establish context = () =>
+ model = AutoMap.Source(new StubTypeSource(typeof(Entity)))
+ .UseOverridesFromAssemblyOf<EntityBatchSizeOverride>()
+ .UseOverridesFromAssemblyOf<EntityTableOverride>();
+
+ Because of = () =>
+ mapping = model.BuildMappingFor<Entity>();
+
+ It should_apply_override_from_the_first_assembly = () =>
+ mapping.BatchSize.ShouldEqual(1234);
+
+ It should_apply_override_from_the_second_assembly = () =>
+ mapping.TableName.ShouldEqual("OverriddenTableName");
+
+ static AutoPersistenceModel model;
+ static ClassMapping mapping;
+ }
}
View
1  src/FluentNHibernate.Specs/Diagnostics/Registration_diagnostics_specs.cs
@@ -5,6 +5,7 @@
using FluentNHibernate.Diagnostics;
using FluentNHibernate.Mapping;
using FluentNHibernate.Specs.Automapping.Fixtures;
+using FluentNHibernate.Specs.ExternalFixtures;
using Machine.Specifications;
namespace FluentNHibernate.Specs.Diagnostics
View
7 src/FluentNHibernate.Specs/FluentNHibernate.Specs.csproj
@@ -86,11 +86,10 @@
<Compile Include="Automapping\AutoPersistenceModelSpecs.cs" />
<Compile Include="Automapping\AutoPersistenceModelSpecs.Conventions.cs" />
<Compile Include="Automapping\Fixtures\AutomappingSpecExtensions.cs" />
- <Compile Include="Automapping\Fixtures\Component.cs" />
- <Compile Include="Automapping\Fixtures\Entity.cs" />
<Compile Include="Automapping\Fixtures\EntityWithStaticProperties.cs" />
<Compile Include="Automapping\Fixtures\EntityUsingPrivateFields.cs" />
<Compile Include="Automapping\Fixtures\FakeMembers.cs" />
+ <Compile Include="Automapping\Fixtures\Overrides\EntityTableOverride.cs" />
<Compile Include="Automapping\Fixtures\StubTypeSource.cs" />
<Compile Include="Automapping\PrivateAutomapperSpecs.cs" />
<Compile Include="Automapping\PrivateFieldsSpecs.cs" />
@@ -141,6 +140,10 @@
<Compile Include="Visitors\BiDirectionalManyToManyPairingVisitorSpecs.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\FluentNHibernate.Specs.ExternalFixtures\FluentNHibernate.Specs.ExternalFixtures.csproj">
+ <Project>{28BF853D-5B20-4091-A059-1CB0A028F981}</Project>
+ <Name>FluentNHibernate.Specs.ExternalFixtures</Name>
+ </ProjectReference>
<ProjectReference Include="..\FluentNHibernate\FluentNHibernate.csproj">
<Project>{529145D5-6CC3-4016-89B5-826563024AF1}</Project>
<Name>FluentNHibernate</Name>
View
12 src/FluentNHibernate.sln
@@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentNHibernate.Specs", "F
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.FirstAutomappedProject", "Examples.FirstAutomappedProject\Examples.FirstAutomappedProject.csproj", "{38CB7FE2-9018-4EF2-A3BA-21A939E70718}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentNHibernate.Specs.ExternalFixtures", "FluentNHibernate.Specs.ExternalFixtures\FluentNHibernate.Specs.ExternalFixtures.csproj", "{28BF853D-5B20-4091-A059-1CB0A028F981}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -84,6 +86,16 @@ Global
{38CB7FE2-9018-4EF2-A3BA-21A939E70718}.Release|Mixed Platforms.Build.0 = Release|x86
{38CB7FE2-9018-4EF2-A3BA-21A939E70718}.Release|x86.ActiveCfg = Release|x86
{38CB7FE2-9018-4EF2-A3BA-21A939E70718}.Release|x86.Build.0 = Release|x86
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Release|Any CPU.Build.0 = Release|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {28BF853D-5B20-4091-A059-1CB0A028F981}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Please sign in to comment.
Something went wrong with that request. Please try again.