diff --git a/.gitignore b/.gitignore index a62522e..97b831b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ _ReSharper* *ReSharper.* *.suo *.cache -* Thumbs.db \ No newline at end of file +* Thumbs.db +*.user +**/packages/** \ No newline at end of file diff --git a/src/Castle.ActiveRecord.Framework.Internal.Tests/App.config b/src/Castle.ActiveRecord.Framework.Internal.Tests/App.config index d167f95..deefe26 100644 --- a/src/Castle.ActiveRecord.Framework.Internal.Tests/App.config +++ b/src/Castle.ActiveRecord.Framework.Internal.Tests/App.config @@ -1,21 +1,19 @@ - + -
-
+
+
- - - + + + @@ -46,4 +44,20 @@ --> + + + + + + + + + + + + + + + + diff --git a/src/Castle.ActiveRecord.Framework.Internal.Tests/AssemblyXmlGenerationTestCase.cs b/src/Castle.ActiveRecord.Framework.Internal.Tests/AssemblyXmlGenerationTestCase.cs index 3cfbfae..9eb4ec4 100644 --- a/src/Castle.ActiveRecord.Framework.Internal.Tests/AssemblyXmlGenerationTestCase.cs +++ b/src/Castle.ActiveRecord.Framework.Internal.Tests/AssemblyXmlGenerationTestCase.cs @@ -62,14 +62,9 @@ public void CanGetCustomValueFromRawXmlDerivedAttribute() public void WillUseRegisteredAssembliesToLookForRawMappingXmlEvenIfThereAreNoActiveRecordTypesInThatAssembly() { ActiveRecordStarter.ResetInitializationFlag(); - ActiveRecordStarter.Initialize( - typeof(RegisterNHibernateClassMapping).Assembly, - GetConfigSource() - ); - ISessionFactory factory = ActiveRecordMediator.GetSessionFactoryHolder() - .GetSessionFactory(typeof(ActiveRecordBase)); - IClassMetadata metadata = factory - .GetClassMetadata(typeof(NHibernateClass)); + ActiveRecordStarter.Initialize(typeof(RegisterNHibernateClassMapping).Assembly, GetConfigSource()); + ISessionFactory factory = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(typeof(ActiveRecordBase)); + IClassMetadata metadata = factory.GetClassMetadata(typeof(NHibernateClass)); Assert.IsNotNull(metadata); } } diff --git a/src/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests-vs2010.csproj b/src/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests-vs2010.csproj index 15d8eb1..90b359a 100644 --- a/src/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests-vs2010.csproj +++ b/src/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests-vs2010.csproj @@ -6,6 +6,7 @@ Client NET40-Debug AnyCPU + 2b20b678 Local @@ -100,17 +101,17 @@ False ..\..\lib\$(BuildConfigKey)\Castle.Components.Validator.dll - - False - ..\..\lib\$(BuildConfigKey)\Castle.Core.dll + + ..\..\packages\Castle.Core.3.3.3\lib\net40-client\Castle.Core.dll + True - - False - ..\..\lib\Iesi.Collections.dll + + ..\..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll + True - - False - ..\..\lib\NHibernate.dll + + ..\..\packages\NHibernate.4.0.3.4000\lib\net40\NHibernate.dll + True nunit.framework @@ -126,6 +127,10 @@ System.Data + + ..\..\packages\System.Data.SQLite.Core.1.0.96.0\lib\net40\System.Data.SQLite.dll + True + System.XML @@ -247,6 +252,7 @@ + @@ -291,4 +297,11 @@ xcopy "$(ProjectDir)App.config" "$(TargetDir)" /y/c move /y "$(TargetDir)App.config" "$(TargetDir)$(TargetFileName).config" + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/Company.cs b/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/Company.cs index 37461f7..9af3eb6 100644 --- a/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/Company.cs +++ b/src/Castle.ActiveRecord.Framework.Internal.Tests/Model/Company.cs @@ -17,7 +17,7 @@ namespace Castle.ActiveRecord.Framework.Internal.Tests.Model /// /// Warning: This is a wrong definition! /// - [ActiveRecord(DiscriminatorColumn="column", DiscriminatorValue="1"), JoinedBase] + [ActiveRecord(DiscriminatorColumn = "column", DiscriminatorValue = "1"), JoinedBase] public class Company : ActiveRecordBase { public Company() diff --git a/src/Castle.ActiveRecord.Framework.Internal.Tests/packages.config b/src/Castle.ActiveRecord.Framework.Internal.Tests/packages.config new file mode 100644 index 0000000..73cd3e3 --- /dev/null +++ b/src/Castle.ActiveRecord.Framework.Internal.Tests/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Castle.ActiveRecord.Tests.Model/Castle.ActiveRecord.Tests.Model-vs2010.csproj b/src/Castle.ActiveRecord.Tests.Model/Castle.ActiveRecord.Tests.Model-vs2010.csproj index 5ebf5bc..c4f0eb2 100644 --- a/src/Castle.ActiveRecord.Tests.Model/Castle.ActiveRecord.Tests.Model-vs2010.csproj +++ b/src/Castle.ActiveRecord.Tests.Model/Castle.ActiveRecord.Tests.Model-vs2010.csproj @@ -4,8 +4,9 @@ $(MSBuildProjectDirectory)\..\.. v4.0 Client - NET40-Debug + NET40-Debug AnyCPU + c355086d 9.0.30729 @@ -21,11 +22,10 @@ 3.5 - v4.0 - + bin\NET40-Debug\ true full @@ -42,7 +42,7 @@ v4.0 - + bin\NET40-Release\ pdbonly true @@ -81,20 +81,27 @@ AnyCPU prompt - False ..\..\lib\$(BuildConfigKey)\Castle.Components.Validator.dll - - False - ..\..\lib\NHibernate.dll + + ..\..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll + True + + + ..\..\packages\NHibernate.4.0.3.4000\lib\net40\NHibernate.dll + True 3.5 + + ..\..\packages\System.Data.SQLite.Core.1.0.96.0\lib\net40\System.Data.SQLite.dll + True + 3.5 @@ -140,9 +147,20 @@ Castle.ActiveRecord-vs2010 + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Castle.ActiveRecord.Tests/App-net-3.5.config b/src/Castle.ActiveRecord.Tests/App-net-3.5.config index 561d675..ad30acc 100644 --- a/src/Castle.ActiveRecord.Tests/App-net-3.5.config +++ b/src/Castle.ActiveRecord.Tests/App-net-3.5.config @@ -1,55 +1,55 @@ - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -57,25 +57,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/src/Castle.ActiveRecord.Tests/App.config b/src/Castle.ActiveRecord.Tests/App.config index d65f0e7..ea66eff 100644 --- a/src/Castle.ActiveRecord.Tests/App.config +++ b/src/Castle.ActiveRecord.Tests/App.config @@ -1,65 +1,85 @@ - + - -
-
+
+
- - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - + - - - - - - + + + + + + - + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2010.csproj b/src/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2010.csproj index 2ffae67..3742a52 100644 --- a/src/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2010.csproj +++ b/src/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2010.csproj @@ -6,6 +6,7 @@ Client NET40-Debug AnyCPU + 5454b8ca Local @@ -99,44 +100,44 @@ Castle.ActiveRecord.Tests.Model-vs2010 - {3A0B9A64-8140-429E-A3F0-5B1617CEB466} + {3a0b9a64-8140-429e-a3f0-5b1617ceb466} Castle.ActiveRecord.Web - {652F95D4-86E2-40B6-919D-CFC6E449386B} + {652f95d4-86e2-40b6-919d-cfc6e449386b} Castle.ActiveRecord-vs2010 False ..\..\lib\$(BuildConfigKey)\Castle.Components.Validator.dll - - False - ..\..\lib\$(BuildConfigKey)\Castle.Core.dll + + ..\..\packages\Castle.Core.3.3.3\lib\net40-client\Castle.Core.dll + True - - False - ..\..\lib\Iesi.Collections.dll + + ..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + True + + + ..\..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll + True False ..\..\lib\$(BuildConfigKey)\log4net.dll - - False - ..\..\lib\Lucene.Net.dll + + ..\..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll + True - - False - ..\..\lib\NHibernate.dll + + ..\..\packages\NHibernate.4.0.3.4000\lib\net40\NHibernate.dll + True - - False - ..\..\lib\NHibernate.ByteCode.Castle.dll - - - False - ..\..\lib\NHibernate.Search.dll + + ..\..\packages\NHibernate.Search.MB.4.0.3.4000\lib\net40\NHibernate.Search.dll + True nunit.framework @@ -152,9 +153,9 @@ System.Data - - False - ..\..\lib\$(BuildConfigKey)\System.Data.SQLite.DLL + + ..\..\packages\System.Data.SQLite.Core.1.0.96.0\lib\net40\System.Data.SQLite.dll + True System.XML @@ -332,6 +333,7 @@ + @@ -440,4 +442,11 @@ + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/src/Castle.ActiveRecord.Tests/Config/ConfigurationSource.cs b/src/Castle.ActiveRecord.Tests/Config/ConfigurationSource.cs index c03c786..aa9fad8 100644 --- a/src/Castle.ActiveRecord.Tests/Config/ConfigurationSource.cs +++ b/src/Castle.ActiveRecord.Tests/Config/ConfigurationSource.cs @@ -232,9 +232,9 @@ private static string GetDefaultHibernateConfigAndCloseActiveRecordSection() { return @" - + - + "; } diff --git a/src/Castle.ActiveRecord.Tests/Config/ConfigureTests.cs b/src/Castle.ActiveRecord.Tests/Config/ConfigureTests.cs index 8fbdfe9..113850a 100644 --- a/src/Castle.ActiveRecord.Tests/Config/ConfigureTests.cs +++ b/src/Castle.ActiveRecord.Tests/Config/ConfigureTests.cs @@ -58,7 +58,7 @@ public void BasicSyntaxStorageConfiguration() .ConnectionStringName("a_string") .Driver() .ConnectionProvider() - .Dialect() + .Dialect() .ProxiedBy() .ShowSql(); diff --git a/src/Castle.ActiveRecord.Tests/Config/StorageConfigurationTests.cs b/src/Castle.ActiveRecord.Tests/Config/StorageConfigurationTests.cs index cad4525..e12630f 100644 --- a/src/Castle.ActiveRecord.Tests/Config/StorageConfigurationTests.cs +++ b/src/Castle.ActiveRecord.Tests/Config/StorageConfigurationTests.cs @@ -67,7 +67,7 @@ public void ConnectionProviderClassIsAdded() [Test] public void DialectIsAdded() { - AssertConfiguration(_configuration.Dialect(), "dialect", "NHibernate.Dialect.MsSql2005Dialect"); + AssertConfiguration(_configuration.Dialect(), "dialect", "NHibernate.Dialect.MsSql2012Dialect"); } [Test] diff --git a/src/Castle.ActiveRecord.Tests/DefaultConfigurationsTestCase.cs b/src/Castle.ActiveRecord.Tests/DefaultConfigurationsTestCase.cs index ea3c4c3..dccf891 100644 --- a/src/Castle.ActiveRecord.Tests/DefaultConfigurationsTestCase.cs +++ b/src/Castle.ActiveRecord.Tests/DefaultConfigurationsTestCase.cs @@ -53,7 +53,7 @@ public void SetUp() public void SqlServer2005Defaults() { var configuration = BuildConfiguration("MsSqlServer2005"); - AssertPropertyEquals(configuration, dialect, typeof(MsSql2005Dialect).AssemblyQualifiedName); + AssertPropertyEquals(configuration, dialect, typeof(MsSql2012Dialect).AssemblyQualifiedName); AssertPropertyEquals(configuration, connection_provider, typeof(DriverConnectionProvider).AssemblyQualifiedName); AssertPropertyEquals(configuration, connection_driver_class, typeof(SqlClientDriver).AssemblyQualifiedName); AssertPropertyEquals(configuration, proxyfactory_factory_class, typeof(ProxyFactoryFactory).AssemblyQualifiedName); @@ -80,7 +80,7 @@ public void Throws_when_connectionStringName_not_specified() var value = @" "; - TestDelegate action = () => + TestDelegate action = () => BuildConfiguration(ReadConfiguration(value)); @@ -117,7 +117,7 @@ public void Throws_when_invalid_database_specified() var ex = Assert.Throws(action); Assert.AreEqual( - "Specified value (IDontExist!) is not valid for 'database' attribute. Valid values are: 'MsSqlServer2000' 'MsSqlServer2005' 'MsSqlServer2008' " + + "Specified value (IDontExist!) is not valid for 'database' attribute. Valid values are: 'MsSqlServer2000' 'MsSqlServer2005' 'MsSqlServer2008' 'MsSqlServer2012' " + "'SQLite' 'MySql' 'MySql5' 'Firebird' 'PostgreSQL' 'PostgreSQL81' 'PostgreSQL82' 'MsSqlCe' 'Oracle8i' 'Oracle9i' 'Oracle10g'.", ex.Message); } @@ -129,7 +129,7 @@ public void Can_use_shorthand_attribute_form() "; var configuration = BuildConfiguration(ReadConfiguration(value)); - AssertPropertyEquals(configuration, dialect, typeof(MsSql2005Dialect).AssemblyQualifiedName); + AssertPropertyEquals(configuration, dialect, typeof(MsSql2012Dialect).AssemblyQualifiedName); AssertPropertyEquals(configuration, connection_connection_string_name, "foobar"); } diff --git a/src/Castle.ActiveRecord.Tests/Event/EventListenerAttributeTest.cs b/src/Castle.ActiveRecord.Tests/Event/EventListenerAttributeTest.cs index fbbfdf7..0034ef5 100644 --- a/src/Castle.ActiveRecord.Tests/Event/EventListenerAttributeTest.cs +++ b/src/Castle.ActiveRecord.Tests/Event/EventListenerAttributeTest.cs @@ -18,6 +18,8 @@ namespace Castle.ActiveRecord.Tests.Event { using Iesi.Collections; using System; + using System.Collections.Generic; + using NUnit.Framework; using Castle.ActiveRecord; using Castle.ActiveRecord.Tests.Model; @@ -37,7 +39,7 @@ public void C1_ListenerMustBeAddedWhenInitialized() public void C1_Listener_must_be_added_when_initialized_with_assembly() { ActiveRecordStarter.Initialize(Assembly.GetAssembly(typeof(AttributedPreLoadListener)), GetConfigSource()); - AssertListenerWasRegistered(e=>e.PreLoadEventListeners); + AssertListenerWasRegistered(e => e.PreLoadEventListeners); } [Test] @@ -117,7 +119,7 @@ public void U3d_Multiple_events_are_served_by_different_instances_by_default() { InitializeSingleBase(typeof(MultipleListener)); Assert.AreNotSame(Array.Find(GetRegisteredListeners(e => e.PreLoadEventListeners), l => (l is MultipleListener)), - Array.Find(GetRegisteredListeners(e => e.PostLoadEventListeners), l => (l is MultipleListener))); + Array.Find(GetRegisteredListeners(e => e.PostLoadEventListeners), l => (l is MultipleListener))); } [Test] @@ -128,21 +130,21 @@ public void U3d_Multiple_events_are_served_by_the_same_instance_when_singleton_i Array.Find(GetRegisteredListeners(e => e.PostLoadEventListeners), l => (l is MultipleSingletonListener))); } - [Test] - public void Event_listeners_are_registered_only_once() - { - InitializeSingleBase(typeof(SamplePostInsertListener), typeof(SamplePostUpdateListener), typeof(SamplePostDeleteListener)); - Assert.AreEqual(1, Array.FindAll(GetRegisteredListeners(e => e.PostInsertEventListeners), l => (l is SamplePostInsertListener)).Length); - Assert.AreEqual(1, Array.FindAll(GetRegisteredListeners(e => e.PostUpdateEventListeners), l => (l is SamplePostUpdateListener)).Length); - Assert.AreEqual(1, Array.FindAll(GetRegisteredListeners(e => e.PostDeleteEventListeners), l => (l is SamplePostDeleteListener)).Length); - } + [Test] + public void Event_listeners_are_registered_only_once() + { + InitializeSingleBase(typeof(SamplePostInsertListener), typeof(SamplePostUpdateListener), typeof(SamplePostDeleteListener)); + Assert.AreEqual(1, Array.FindAll(GetRegisteredListeners(e => e.PostInsertEventListeners), l => (l is SamplePostInsertListener)).Length); + Assert.AreEqual(1, Array.FindAll(GetRegisteredListeners(e => e.PostUpdateEventListeners), l => (l is SamplePostUpdateListener)).Length); + Assert.AreEqual(1, Array.FindAll(GetRegisteredListeners(e => e.PostDeleteEventListeners), l => (l is SamplePostDeleteListener)).Length); + } [Test] public void U1_Listeners_are_registered_for_all_configurations() { InitializeMultipleBases(typeof(SamplePreInsertListener)); AssertListenerWasRegistered(e => e.PreInsertEventListeners); - AssertListenerWasRegistered(e=>e.PreInsertEventListeners); + AssertListenerWasRegistered(e => e.PreInsertEventListeners); } [Test] @@ -168,7 +170,7 @@ public void U1_Excluded_Listeners_are_not_registered() [Test] public void U1_C5_U4_No_replacement_on_excluded_configs() { - InitializeMultipleBases(typeof (SecondBaseReplacementLoadListener)); + InitializeMultipleBases(typeof(SecondBaseReplacementLoadListener)); AssertListenerWasNotRegistered(e => e.LoadEventListeners); AssertListenerWasRegistered(e => e.LoadEventListeners); AssertListenerWasRegistered(e => e.LoadEventListeners); @@ -180,81 +182,81 @@ public void U1_C5_U4_No_replacement_on_excluded_configs() [EventListener] private class SamplePreInsertListener : IPreInsertEventListener { - public bool OnPreInsert(PreInsertEvent @event) {return true; } + public bool OnPreInsert(PreInsertEvent @event) { return true; } } - [EventListener] - private class SamplePostInsertListener : IPostInsertEventListener - { - public void OnPostInsert(PostInsertEvent @event) { } - } + [EventListener] + private class SamplePostInsertListener : IPostInsertEventListener + { + public void OnPostInsert(PostInsertEvent @event) { } + } - [EventListener] - private class SamplePostUpdateListener : IPostUpdateEventListener - { - public void OnPostUpdate(PostUpdateEvent @event) { } - } + [EventListener] + private class SamplePostUpdateListener : IPostUpdateEventListener + { + public void OnPostUpdate(PostUpdateEvent @event) { } + } - [EventListener] - private class SamplePostDeleteListener : IPostDeleteEventListener - { - public void OnPostDelete(PostDeleteEvent @event) { } - } + [EventListener] + private class SamplePostDeleteListener : IPostDeleteEventListener + { + public void OnPostDelete(PostDeleteEvent @event) { } + } [EventListener] private class AdditionalLoadListener : ILoadEventListener { - public void OnLoad(LoadEvent @event, LoadType loadType){} + public void OnLoad(LoadEvent @event, LoadType loadType) { } } [EventListener(ReplaceExisting = true)] private class ReplacementLoadListener : ILoadEventListener { - public void OnLoad(LoadEvent @event, LoadType loadType){} + public void OnLoad(LoadEvent @event, LoadType loadType) { } } [EventListener(Ignore = true)] private class IgnoredListener : IPreLoadEventListener { - public void OnPreLoad(PreLoadEvent @event){} + public void OnPreLoad(PreLoadEvent @event) { } } [EventListener(Ignore = true, ReplaceExisting = true)] private class IgnoredReplacementListener : ILoadEventListener { - public void OnLoad(LoadEvent @event, LoadType loadType){} + public void OnLoad(LoadEvent @event, LoadType loadType) { } } [EventListener] private class MultipleListener : IPreLoadEventListener, IPostLoadEventListener { - public void OnPreLoad(PreLoadEvent @event){} - public void OnPostLoad(PostLoadEvent @event){} + public void OnPreLoad(PreLoadEvent @event) { } + public void OnPostLoad(PostLoadEvent @event) { } } - [EventListener(SkipEvent = new[] {typeof (IPreLoadEventListener)})] + [EventListener(SkipEvent = new[] { typeof(IPreLoadEventListener) })] private class MultipleSkippedListener : IPreLoadEventListener, IPostLoadEventListener { - public void OnPreLoad(PreLoadEvent @event){} - public void OnPostLoad(PostLoadEvent @event){} + public void OnPreLoad(PreLoadEvent @event) { } + public void OnPostLoad(PostLoadEvent @event) { } } - [EventListener(SkipEvent = new[] {typeof (ILoadEventListener)})] + [EventListener(SkipEvent = new[] { typeof(ILoadEventListener) })] private class MultipleSkippedReplacementListener : ILoadEventListener, IDeleteEventListener { - public void OnLoad(LoadEvent @event, LoadType loadType){} - public void OnDelete(DeleteEvent @event){} - public void OnDelete(DeleteEvent @event, ISet transientEntities){} + public void OnLoad(LoadEvent @event, LoadType loadType) { } + public void OnDelete(DeleteEvent @event) { } + public void OnDelete(DeleteEvent @event, ISet transientEntities) { } } [EventListener(Singleton = true)] private class MultipleSingletonListener : IPreLoadEventListener, IPostLoadEventListener { - public void OnPreLoad(PreLoadEvent @event){} - public void OnPostLoad(PostLoadEvent @event){} + public void OnPreLoad(PreLoadEvent @event) { } + public void OnPostLoad(PostLoadEvent @event) { } } - [EventListener(Include=new[]{typeof(ActiveRecordBase)})] + [EventListener(Include = new[] { typeof(ActiveRecordBase) })] private class FirstBaseIncludeListener : IPreLoadEventListener { public void OnPreLoad(PreLoadEvent @event) { } @@ -288,16 +290,16 @@ public void OnLoad(LoadEvent @event, LoadType loadType) { } protected static void InitializeSingleBase(params Type[] listenerTypes) { - InitializeWithListeners(listenerTypes, new[] {typeof (Blog), typeof (Post)}); + InitializeWithListeners(listenerTypes, new[] { typeof(Blog), typeof(Post) }); } private static void InitializeWithListeners(Type[] listenerTypes, Type[] arTypes) { var typesToRegister = new Type[listenerTypes.Length + arTypes.Length]; - Array.ConstrainedCopy(arTypes,0,typesToRegister,0,arTypes.Length); - Array.ConstrainedCopy(listenerTypes,0,typesToRegister,arTypes.Length,listenerTypes.Length); + Array.ConstrainedCopy(arTypes, 0, typesToRegister, 0, arTypes.Length); + Array.ConstrainedCopy(listenerTypes, 0, typesToRegister, arTypes.Length, listenerTypes.Length); - ActiveRecordStarter.Initialize(GetConfigSource(),typesToRegister); + ActiveRecordStarter.Initialize(GetConfigSource(), typesToRegister); } protected static void InitializeMultipleBases(params Type[] listenerTypes) diff --git a/src/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs b/src/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs index 87ddf09..c0167cb 100644 --- a/src/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs +++ b/src/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs @@ -26,12 +26,12 @@ protected IConfigurationSource GetConfigSource() { InPlaceConfigurationSource source = new InPlaceConfigurationSource(); - Dictionary properties = new Dictionary(); + Dictionary properties = new Dictionary(); properties.Add("hibernate.connection.driver_class", "NHibernate.Driver.SqlClientDriver"); - properties.Add("hibernate.dialect", "NHibernate.Dialect.MsSql2000Dialect"); + properties.Add("hibernate.dialect", "NHibernate.Dialect.MsSql2012Dialect"); properties.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider"); properties.Add("hibernate.connection.connection_string", - "Data Source=.;Initial Catalog=test;Integrated Security=SSPI"); + "Data Source=.;Initial Catalog=Test;Integrated Security=true"); source.Add(typeof(ActiveRecordBase), properties); source.Add(typeof(NonAbstractRootType), properties); diff --git a/src/Castle.ActiveRecord.Tests/LazyTestCase.cs b/src/Castle.ActiveRecord.Tests/LazyTestCase.cs index e1b7419..b84dabb 100644 --- a/src/Castle.ActiveRecord.Tests/LazyTestCase.cs +++ b/src/Castle.ActiveRecord.Tests/LazyTestCase.cs @@ -46,13 +46,13 @@ public void CanSaveAndLoadLazy() ActiveRecordMediator.Save(lazy); - VeryLazyObject lazyFromDb = (VeryLazyObject) ActiveRecordMediator.FindByPrimaryKey(typeof(VeryLazyObject), lazy.Id); + VeryLazyObject lazyFromDb = (VeryLazyObject)ActiveRecordMediator.FindByPrimaryKey(typeof(VeryLazyObject), lazy.Id); Assert.AreEqual("test", lazyFromDb.Title); lazyFromDb.Title = "test for update"; ActiveRecordMediator.Update(lazyFromDb); - lazyFromDb = (VeryLazyObject) ActiveRecordMediator.FindByPrimaryKey(typeof(VeryLazyObject), lazy.Id); + lazyFromDb = (VeryLazyObject)ActiveRecordMediator.FindByPrimaryKey(typeof(VeryLazyObject), lazy.Id); Assert.AreEqual("test for update", lazyFromDb.Title); } @@ -76,7 +76,7 @@ public void CanLoadLazyProperty() using (new SessionScope()) { - LazyObjectWithLazyBlobProperty lazyFromDb = (LazyObjectWithLazyBlobProperty) ActiveRecordMediator.FindByPrimaryKey(typeof(LazyObjectWithLazyBlobProperty), id); + LazyObjectWithLazyBlobProperty lazyFromDb = (LazyObjectWithLazyBlobProperty)ActiveRecordMediator.FindByPrimaryKey(typeof(LazyObjectWithLazyBlobProperty), id); Assert.True(!NHibernate.NHibernateUtil.IsPropertyInitialized(lazyFromDb, "BlobData")); byte[] fromDb = lazyFromDb.BlobData; @@ -89,8 +89,8 @@ public void CanLoadLazyProperty() [Test] public void CanLoadLazyBelongsToOutsideOfScope() { - ActiveRecordStarter.Initialize(GetConfigSource(), typeof(ScopelessLazy), typeof(ObjectWithLazyAssociation), typeof(VeryLazyObject2)); - + ActiveRecordStarter.Initialize(GetConfigSource(), typeof(ScopelessLazy), typeof(ObjectWithLazyAssociation), typeof(VeryLazyObject2)); + Recreate(); var lazy = new VeryLazyObject2(); @@ -101,7 +101,7 @@ public void CanLoadLazyBelongsToOutsideOfScope() obj.LazyObj = lazy; ActiveRecordMediator.Save(obj); - var objFromDb = (ObjectWithLazyAssociation) ActiveRecordMediator.FindByPrimaryKey(typeof(ObjectWithLazyAssociation), obj.Id); + var objFromDb = (ObjectWithLazyAssociation)ActiveRecordMediator.FindByPrimaryKey(typeof(ObjectWithLazyAssociation), obj.Id); Assert.False(NHibernate.NHibernateUtil.IsInitialized(objFromDb.LazyObj)); Assert.AreEqual("test", objFromDb.LazyObj.Title); Assert.True(NHibernate.NHibernateUtil.IsInitialized(objFromDb.LazyObj)); diff --git a/src/Castle.ActiveRecord.Tests/Model/AnyModel/Models.cs b/src/Castle.ActiveRecord.Tests/Model/AnyModel/Models.cs index f346203..6c5f096 100644 --- a/src/Castle.ActiveRecord.Tests/Model/AnyModel/Models.cs +++ b/src/Castle.ActiveRecord.Tests/Model/AnyModel/Models.cs @@ -16,7 +16,7 @@ namespace Castle.ActiveRecord.Tests.Model.AnyModel { using System; using System.Collections; - + [ActiveRecord("Orders")] public class Order : ActiveRecordBase { @@ -129,7 +129,7 @@ public interface IPayment public class ModelWithInCorrectMapping : ActiveRecordBase { private string payment; - + [Any.MetaValue("CREDIT_CARD", typeof(CreditCards))] [Any.MetaValue("BANK_ACCOUNT", typeof(BankAccounts))] public string Payment diff --git a/src/Castle.ActiveRecord.Tests/Model/Blog.cs b/src/Castle.ActiveRecord.Tests/Model/Blog.cs index 66976c1..224b119 100644 --- a/src/Castle.ActiveRecord.Tests/Model/Blog.cs +++ b/src/Castle.ActiveRecord.Tests/Model/Blog.cs @@ -16,6 +16,8 @@ namespace Castle.ActiveRecord.Tests.Model { using System; using System.Collections; + using System.Collections.Generic; + using Castle.ActiveRecord.Framework; using NHibernate; using NHibernate.Criterion; @@ -26,10 +28,10 @@ public class Blog : ActiveRecordBase private int _id; private String _name; private String _author; - private IList _posts; - private IList _publishedposts; - private IList _unpublishedposts; - private IList _recentposts; + private IList _posts; + private IList _publishedposts; + private IList _unpublishedposts; + private IList _recentposts; private bool onSaveCalled, onUpdateCalled, onDeleteCalled, onLoadCalled; public Blog() @@ -62,29 +64,29 @@ public String Author set { _author = value; } } - [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid")] - public IList Posts + [HasMany(typeof(Post), Table = "Posts", ColumnKey = "blogid")] + public IList Posts { get { return _posts; } set { _posts = value; } } - [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid", Where="published = 1")] - public IList PublishedPosts + [HasMany(typeof(Post), Table = "Posts", ColumnKey = "blogid", Where = "published = 1")] + public IList PublishedPosts { get { return _publishedposts; } set { _publishedposts = value; } } - [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid", Where="published = 0")] - public IList UnPublishedPosts + [HasMany(typeof(Post), Table = "Posts", ColumnKey = "blogid", Where = "published = 0")] + public IList UnPublishedPosts { get { return _unpublishedposts; } set { _unpublishedposts = value; } } - [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid", OrderBy="created desc")] - public IList RecentPosts + [HasMany(typeof(Post), Table = "Posts", ColumnKey = "blogid", OrderBy = "created desc")] + public IList RecentPosts { get { return _recentposts; } set { _recentposts = value; } @@ -105,23 +107,23 @@ public static void DeleteAll(string where) public static Blog[] FindAll() { - return (Blog[]) ActiveRecordMediator.FindAll(typeof(Blog)); + return (Blog[])ActiveRecordMediator.FindAll(typeof(Blog)); } - public static Blog[] FindAll(IDetachedQuery dq) - { - return (Blog[]) FindAll(typeof(Blog), dq); - } + public static Blog[] FindAll(IDetachedQuery dq) + { + return (Blog[])FindAll(typeof(Blog), dq); + } public static Blog Find(int id) { - return (Blog) ActiveRecordMediator.FindByPrimaryKey(typeof(Blog), id); + return (Blog)ActiveRecordMediator.FindByPrimaryKey(typeof(Blog), id); } - public static Blog FindOne(IDetachedQuery dq) - { - return (Blog) FindOne(typeof(Blog), dq); - } + public static Blog FindOne(IDetachedQuery dq) + { + return (Blog)FindOne(typeof(Blog), dq); + } public static int FetchCount() { @@ -158,24 +160,24 @@ public static bool Exists(params ICriterion[] criteria) return Exists(typeof(Blog), criteria); } - public static bool Exists(IDetachedQuery dq) - { - return Exists(typeof(Blog), dq); - } + public static bool Exists(IDetachedQuery dq) + { + return Exists(typeof(Blog), dq); + } - public static Blog[] SlicedFindAll(int FirstResult, int MaxResult, IDetachedQuery dq) - { - return (Blog[]) SlicedFindAll(typeof(Blog), FirstResult, MaxResult, dq); - } + public static Blog[] SlicedFindAll(int FirstResult, int MaxResult, IDetachedQuery dq) + { + return (Blog[])SlicedFindAll(typeof(Blog), FirstResult, MaxResult, dq); + } public static Blog[] FindByProperty(String property, object value) { - return (Blog[]) FindAllByProperty(typeof(Blog), property, value); + return (Blog[])FindAllByProperty(typeof(Blog), property, value); } public static Blog[] FindByProperty(String property, String orderByColumn, object value) { - return (Blog[]) FindAllByProperty(typeof(Blog), orderByColumn, property, value); + return (Blog[])FindAllByProperty(typeof(Blog), orderByColumn, property, value); } /// @@ -235,7 +237,7 @@ public ISession CurrentSession get { return (ISession) - ActiveRecordMediator.Execute(typeof(Blog), new NHibernateDelegate(GrabSession), this); + ActiveRecordMediator.Execute(typeof(Blog), new NHibernateDelegate(GrabSession), this); } } diff --git a/src/Castle.ActiveRecord.Tests/Model/Company.cs b/src/Castle.ActiveRecord.Tests/Model/Company.cs index 590e5c4..9c9a1af 100644 --- a/src/Castle.ActiveRecord.Tests/Model/Company.cs +++ b/src/Castle.ActiveRecord.Tests/Model/Company.cs @@ -18,7 +18,7 @@ namespace Castle.ActiveRecord.Tests.Model using System.Collections; - [ActiveRecord("Companies", DiscriminatorColumn="type", DiscriminatorType="String", DiscriminatorValue="company")] + [ActiveRecord("Companies", DiscriminatorColumn = "type", DiscriminatorType = "String", DiscriminatorValue = "company")] public class Company : ActiveRecordBase { private int id; @@ -56,8 +56,8 @@ public PostalAddress Address set { _address = value; } } - [HasAndBelongsToMany( typeof(Person), RelationType.Bag, - Table="PeopleCompanies", ColumnRef="person_id", ColumnKey="company_id" )] + [HasAndBelongsToMany(typeof(Person), RelationType.Bag, + Table = "PeopleCompanies", ColumnRef = "person_id", ColumnKey = "company_id")] public IList People { get { return _people; } @@ -66,17 +66,17 @@ public IList People public static void DeleteAll() { - ActiveRecordBase.DeleteAll( typeof(Company) ); + ActiveRecordBase.DeleteAll(typeof(Company)); } public static Company[] FindAll() { - return (Company[]) ActiveRecordBase.FindAll( typeof(Company) ); + return (Company[])ActiveRecordBase.FindAll(typeof(Company)); } public static Company Find(int id) { - return (Company) ActiveRecordBase.FindByPrimaryKey( typeof(Company), id ); + return (Company)ActiveRecordBase.FindByPrimaryKey(typeof(Company), id); } } @@ -111,7 +111,7 @@ public String Address public String City { get { return _city; } - set { _city = value;} + set { _city = value; } } [Property] diff --git a/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Agent.cs b/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Agent.cs index 5c1ee69..15c9482 100644 --- a/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Agent.cs +++ b/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Agent.cs @@ -16,6 +16,7 @@ namespace Castle.ActiveRecord.Tests.Model.CompositeModel { using System; using System.Collections; + using System.Collections.Generic; using NHibernate; @@ -27,16 +28,17 @@ public class Agent : ActiveRecordBase { private AgentKey _userKey; private Org _org; - private IList _groups; + private IList _groups; private int _version; public Agent() { - _groups = new ArrayList(); + _groups = new List(); _version = -1; } - public Agent(AgentKey key) : this() + public Agent(AgentKey key) + : this() { _userKey = key; } @@ -58,27 +60,27 @@ public String Name get { return _userKey.Name; } } - [Version(UnsavedValue="negative")] + [Version(UnsavedValue = "negative")] public int Version { - get{ return _version; } - set{ _version = value; } + get { return _version; } + set { _version = value; } } - [BelongsTo("OrgId", Insert=false, Update=false)] + [BelongsTo("OrgId", Insert = false, Update = false)] public Org Org { get { return _org; } set { _org = value; } } - [HasAndBelongsToMany(typeof (Group), + [HasAndBelongsToMany(typeof(Group), Table = "GroupAgents", ColumnRef = "GroupId", - CompositeKeyColumnKeys = new String[]{"OrgId","Name"}, + CompositeKeyColumnKeys = new String[] { "OrgId", "Name" }, Lazy = true, Cascade = ManyRelationCascadeEnum.SaveUpdate)] - public IList Groups + public IList Groups { get { return _groups; } set { _groups = value; } @@ -86,17 +88,17 @@ public IList Groups public static void DeleteAll() { - ActiveRecordBase.DeleteAll( typeof(Agent) ); + ActiveRecordBase.DeleteAll(typeof(Agent)); } public static Agent[] FindAll() { - return (Agent[]) ActiveRecordBase.FindAll( typeof(Agent) ); + return (Agent[])ActiveRecordBase.FindAll(typeof(Agent)); } public static Agent Find(object key) { - return (Agent) ActiveRecordBase.FindByPrimaryKey( typeof(Agent), key ); + return (Agent)ActiveRecordBase.FindByPrimaryKey(typeof(Agent), key); } /// @@ -116,7 +118,7 @@ private object MyCustomMethod(ISession session, object userInstance) { session.Delete(userInstance); session.Flush(); - + return null; } } diff --git a/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Group.cs b/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Group.cs index 9010110..6ff9972 100644 --- a/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Group.cs +++ b/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Group.cs @@ -16,6 +16,8 @@ namespace Castle.ActiveRecord.Tests.Model.CompositeModel { using System; using System.Collections; + using System.Collections.Generic; + using Castle.ActiveRecord.Framework; using NHibernate; @@ -24,14 +26,14 @@ public class Group : ActiveRecordBase { private int _id; private String _name; - private IList _agents; - private IList _groups; + private IList _agents; + private IList _groups; private bool onSaveCalled, onUpdateCalled, onDeleteCalled, onLoadCalled; public Group() { - _agents = new ArrayList(); - _groups = new ArrayList(); + _agents = new List(); + _groups = new List(); } [PrimaryKey(PrimaryKeyType.Native)] @@ -50,7 +52,7 @@ public String Name [HasAndBelongsToMany(typeof(Agent), Table = "GroupAgents", CompositeKeyColumnRefs = new String[] {"OrgId", "Name"}, ColumnKey = "GroupId", Lazy = true, Inverse=true, Cascade = ManyRelationCascadeEnum.SaveUpdate)] - public IList Agents + public IList Agents { get { return _agents; } set { _agents = value; } @@ -58,7 +60,7 @@ public IList Agents [HasAndBelongsToMany(typeof(Group), Table = "GroupOrgs", ColumnRef = "GroupId", ColumnKey = "OrgId", Lazy = true, Inverse=true, Cascade = ManyRelationCascadeEnum.SaveUpdate)] - public IList Groups + public IList Groups { get { return _groups; } set { _groups = value; } diff --git a/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Org.cs b/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Org.cs index a666cb6..22894f2 100644 --- a/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Org.cs +++ b/src/Castle.ActiveRecord.Tests/Model/CompositeModel/Org.cs @@ -16,6 +16,7 @@ namespace Castle.ActiveRecord.Tests.Model.CompositeModel { using System; using System.Collections; + using System.Collections.Generic; [ActiveRecord("Orgs")] public class Org : ActiveRecordBase @@ -23,17 +24,18 @@ public class Org : ActiveRecordBase private string _id; private String _description; private DateTime _created; - private IList _agents; + private IList _agents; private int _version; public Org() { - _agents = new ArrayList(); + _agents = new List(); _created = DateTime.Now; _version = -1; } - public Org(string id, String description) : this() + public Org(string id, String description) + : this() { _id = id; _description = description; @@ -46,14 +48,14 @@ public string Id set { _id = value; } } - [Version(UnsavedValue="negative")] + [Version(UnsavedValue = "negative")] public int Version { get { return _version; } set { _version = value; } } - [Property(ColumnType="StringClob")] + [Property(ColumnType = "StringClob")] public String Contents { get { return _description; } @@ -61,9 +63,9 @@ public String Contents } [HasMany(typeof(Agent), - Inverse=true, - Lazy=true)] - public IList Agents + Inverse = true, + Lazy = true)] + public IList Agents { get { return _agents; } set { _agents = value; } @@ -89,12 +91,12 @@ public static void DeleteAll() public static Org[] FindAll() { - return (Org[]) FindAll(typeof(Org)); + return (Org[])FindAll(typeof(Org)); } public static Org Find(string id) { - return (Org) FindByPrimaryKey(typeof(Org), id); + return (Org)FindByPrimaryKey(typeof(Org), id); } public static int FetchCount() diff --git a/src/Castle.ActiveRecord.Tests/Model/GenericModel/Company.cs b/src/Castle.ActiveRecord.Tests/Model/GenericModel/Company.cs index 9e2c504..c9222ed 100644 --- a/src/Castle.ActiveRecord.Tests/Model/GenericModel/Company.cs +++ b/src/Castle.ActiveRecord.Tests/Model/GenericModel/Company.cs @@ -16,6 +16,8 @@ namespace Castle.ActiveRecord.Tests.Model.GenericModel { using System; using System.Collections; + using System.Collections.Generic; + using Iesi.Collections.Generic; [ActiveRecord( "Companies", DiscriminatorColumn = "type", DiscriminatorType = "String", DiscriminatorValue = "company" )] @@ -23,7 +25,7 @@ public class Company : ActiveRecordBase { private int id; private String name; - private ISet _people = new HashedSet(); + private ISet _people = new HashSet(); private PostalAddress _address; public Company() diff --git a/src/Castle.ActiveRecord.Tests/Model/GenericModel/Person.cs b/src/Castle.ActiveRecord.Tests/Model/GenericModel/Person.cs index da54351..f674531 100644 --- a/src/Castle.ActiveRecord.Tests/Model/GenericModel/Person.cs +++ b/src/Castle.ActiveRecord.Tests/Model/GenericModel/Person.cs @@ -16,17 +16,18 @@ namespace Castle.ActiveRecord.Tests.Model.GenericModel { using System; using System.Collections; + using System.Collections.Generic; [ActiveRecord("People")] public class Person : ActiveRecordBase { private int _id; private String _name; - private IList _companies; + private IList _companies; public Person() { - _companies = new ArrayList(); + _companies = new List(); } [PrimaryKey] @@ -43,8 +44,8 @@ public string Name set { _name = value; } } - [HasAndBelongsToMany( typeof(Company), RelationType.Bag, Table="PeopleCompanies", ColumnRef="company_id", ColumnKey="person_id" )] - public IList Companies + [HasAndBelongsToMany(typeof(Company), RelationType.Bag, Table = "PeopleCompanies", ColumnRef = "company_id", ColumnKey = "person_id")] + public IList Companies { get { return _companies; } set { _companies = value; } diff --git a/src/Castle.ActiveRecord.Tests/Model/LazyModel/ProductLazy.cs b/src/Castle.ActiveRecord.Tests/Model/LazyModel/ProductLazy.cs index d465d5c..fca7b63 100644 --- a/src/Castle.ActiveRecord.Tests/Model/LazyModel/ProductLazy.cs +++ b/src/Castle.ActiveRecord.Tests/Model/LazyModel/ProductLazy.cs @@ -15,6 +15,7 @@ namespace Castle.ActiveRecord.Tests.Model.LazyModel { using System; + using System.Collections.Generic; using Iesi.Collections; @@ -23,7 +24,7 @@ namespace Castle.ActiveRecord.Tests.Model.LazyModel public class ProductLazy : ActiveRecordValidationBase { private int id; - private ISet categories = new HashedSet(); + private ISet categories = new HashSet(); public ProductLazy() { @@ -36,8 +37,8 @@ public int Id set { id = value; } } - [HasMany( typeof(CategoryLazy), Lazy=true, Cascade=ManyRelationCascadeEnum.All )] - public ISet Categories + [HasMany(typeof(CategoryLazy), Lazy = true, Cascade = ManyRelationCascadeEnum.All)] + public ISet Categories { get { return categories; } set { categories = value; } @@ -45,17 +46,17 @@ public ISet Categories public static void DeleteAll() { - ActiveRecordBase.DeleteAll( typeof(ProductLazy) ); + ActiveRecordBase.DeleteAll(typeof(ProductLazy)); } public static ProductLazy[] FindAll() { - return (ProductLazy[]) ActiveRecordBase.FindAll( typeof(ProductLazy) ); + return (ProductLazy[])ActiveRecordBase.FindAll(typeof(ProductLazy)); } public static ProductLazy Find(int id) { - return (ProductLazy) ActiveRecordBase.FindByPrimaryKey( typeof(ProductLazy), id ); + return (ProductLazy)ActiveRecordBase.FindByPrimaryKey(typeof(ProductLazy), id); } } diff --git a/src/Castle.ActiveRecord.Tests/Model/Order.cs b/src/Castle.ActiveRecord.Tests/Model/Order.cs index 46bcdb5..8d97d23 100644 --- a/src/Castle.ActiveRecord.Tests/Model/Order.cs +++ b/src/Castle.ActiveRecord.Tests/Model/Order.cs @@ -16,6 +16,7 @@ namespace Castle.ActiveRecord.Tests.Model { using System; using System.Collections; + using System.Collections.Generic; using Iesi.Collections; @@ -26,7 +27,7 @@ public class Order : ActiveRecordBase private int id; private DateTime ordered_date; private Boolean shipped; - private ISet _products; + private ISet _products; [PrimaryKey(PrimaryKeyType.Native, "OrderID")] public int ID @@ -51,13 +52,13 @@ public Boolean IsShipped public static Order Find(int id) { - return ((Order) (ActiveRecordBase.FindByPrimaryKey(typeof (Order), id))); + return ((Order)(ActiveRecordBase.FindByPrimaryKey(typeof(Order), id))); } - [HasAndBelongsToMany(typeof (Product), RelationType.Set, - Table="line_item", - ColumnRef="product_id", ColumnKey="order_id")] - public ISet Products + [HasAndBelongsToMany(typeof(Product), RelationType.Set, + Table = "line_item", + ColumnRef = "product_id", ColumnKey = "order_id")] + public ISet Products { get { return _products; } set { _products = value; } @@ -65,7 +66,7 @@ public ISet Products public static void DeleteAll() { - ActiveRecordBase.DeleteAll(typeof (Order)); + ActiveRecordBase.DeleteAll(typeof(Order)); } } @@ -75,7 +76,7 @@ public class OrderWithIDBag : ActiveRecordBase private int id; private DateTime ordered_date; private Boolean shipped; - private IList _products; + private IList _products; [PrimaryKey(PrimaryKeyType.Native, "OrderID")] public int ID @@ -100,15 +101,15 @@ public Boolean IsShipped public static OrderWithIDBag Find(int id) { - return ((OrderWithIDBag) (ActiveRecordBase.FindByPrimaryKey(typeof (OrderWithIDBag), id))); + return ((OrderWithIDBag)(ActiveRecordBase.FindByPrimaryKey(typeof(OrderWithIDBag), id))); } - [HasAndBelongsToMany(typeof (ProductWithIDBag), RelationType.IdBag, - Table="line_item_non_ident", - ColumnRef="product_id", ColumnKey="order_id"), + [HasAndBelongsToMany(typeof(ProductWithIDBag), RelationType.IdBag, + Table = "line_item_non_ident", + ColumnRef = "product_id", ColumnKey = "order_id"), CollectionID(CollectionIDType.HiLo, "line_number", "Int32"), - Hilo(Table="testing_hilo", Column="sequence", MaxLo=150)] - public IList Products + Hilo(Table = "testing_hilo", Column = "sequence", MaxLo = 150)] + public IList Products { get { return _products; } set { _products = value; } @@ -116,7 +117,7 @@ public IList Products public static void DeleteAll() { - ActiveRecordBase.DeleteAll(typeof (OrderWithIDBag)); + ActiveRecordBase.DeleteAll(typeof(OrderWithIDBag)); } } } diff --git a/src/Castle.ActiveRecord.Tests/Model/Person.cs b/src/Castle.ActiveRecord.Tests/Model/Person.cs index d69559a..33e7c16 100644 --- a/src/Castle.ActiveRecord.Tests/Model/Person.cs +++ b/src/Castle.ActiveRecord.Tests/Model/Person.cs @@ -16,8 +16,9 @@ namespace Castle.ActiveRecord.Tests.Model { using System; using System.Collections; + using System.Collections.Generic; - [ActiveRecord("People"), + [ActiveRecord("People"), JoinedTable("Addresses", Column = "person_id")] public class Person : ActiveRecordBase { @@ -25,12 +26,12 @@ public class Person : ActiveRecordBase private String _name; private FullName _fullName; private String _address; - private IList _companies; + private IList _companies; private Blog _blog; public Person() { - _companies = new ArrayList(); + _companies = new List(); } [PrimaryKey] @@ -72,7 +73,7 @@ public Blog Blog } [HasAndBelongsToMany( typeof(Company), RelationType.Bag, Table="PeopleCompanies", ColumnRef="company_id", ColumnKey="person_id" )] - public IList Companies + public IList Companies { get { return _companies; } set { _companies = value; } diff --git a/src/Castle.ActiveRecord.Tests/Model/Product.cs b/src/Castle.ActiveRecord.Tests/Model/Product.cs index 8bdf0aa..00f872f 100644 --- a/src/Castle.ActiveRecord.Tests/Model/Product.cs +++ b/src/Castle.ActiveRecord.Tests/Model/Product.cs @@ -1,4 +1,4 @@ - // Copyright 2004-2011 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2011 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ namespace Castle.ActiveRecord.Tests.Model { using System.Collections; + using System.Collections.Generic; + using Iesi.Collections; [ActiveRecord("Product")] @@ -24,7 +26,7 @@ public class Product : ActiveRecordBase private string product_name; private float price; private string serial_number; - private ISet _orders; + private ISet _orders; [PrimaryKey(PrimaryKeyType.Native, "ProductID")] public int ID @@ -54,10 +56,10 @@ public float Price set { this.price = value; } } - [HasAndBelongsToMany(typeof (Order), RelationType.Set, - Table="line_item", - ColumnRef="order_id", ColumnKey="product_id", Inverse=true)] - public ISet Orders + [HasAndBelongsToMany(typeof(Order), RelationType.Set, + Table = "line_item", + ColumnRef = "order_id", ColumnKey = "product_id", Inverse = true)] + public ISet Orders { get { return _orders; } set { _orders = value; } @@ -65,12 +67,12 @@ public ISet Orders public static Product Find(int id) { - return ((Product) (ActiveRecordBase.FindByPrimaryKey(typeof (Product), id))); + return ((Product)(ActiveRecordBase.FindByPrimaryKey(typeof(Product), id))); } public static void DeleteAll() { - ActiveRecordBase.DeleteAll(typeof (Product)); + ActiveRecordBase.DeleteAll(typeof(Product)); } } @@ -111,11 +113,11 @@ public float Price set { this.price = value; } } - [HasAndBelongsToMany(typeof (OrderWithIDBag), RelationType.IdBag, - Table="line_item_non_ident", - ColumnRef="order_id", ColumnKey="product_id"), + [HasAndBelongsToMany(typeof(OrderWithIDBag), RelationType.IdBag, + Table = "line_item_non_ident", + ColumnRef = "order_id", ColumnKey = "product_id"), CollectionID(CollectionIDType.HiLo, "line_number", "Int32"), - Hilo(Table="testing_hilo", Column="sequence", MaxLo=150)] + Hilo(Table = "testing_hilo", Column = "sequence", MaxLo = 150)] public IList Orders { get { return _orders; } @@ -124,12 +126,12 @@ public IList Orders public static ProductWithIDBag Find(int id) { - return ((ProductWithIDBag) (ActiveRecordBase.FindByPrimaryKey(typeof (ProductWithIDBag), id))); + return ((ProductWithIDBag)(ActiveRecordBase.FindByPrimaryKey(typeof(ProductWithIDBag), id))); } public static void DeleteAll() { - ActiveRecordBase.DeleteAll(typeof (ProductWithIDBag)); + ActiveRecordBase.DeleteAll(typeof(ProductWithIDBag)); } } } diff --git a/src/Castle.ActiveRecord.Tests/Model/StrictModel/Estrato.cs b/src/Castle.ActiveRecord.Tests/Model/StrictModel/Estrato.cs index b7157fb..8dec3d3 100644 --- a/src/Castle.ActiveRecord.Tests/Model/StrictModel/Estrato.cs +++ b/src/Castle.ActiveRecord.Tests/Model/StrictModel/Estrato.cs @@ -15,6 +15,7 @@ namespace Castle.ActiveRecord.Tests.Model.StrictModel { using System; + using System.Collections.Generic; using Iesi.Collections; @@ -25,15 +26,15 @@ public enum EstratoType Survey } - [ActiveRecord(DiscriminatorColumn="type", DiscriminatorType="Int16", DiscriminatorValue="0")] + [ActiveRecord(DiscriminatorColumn = "type", DiscriminatorType = "Int16", DiscriminatorValue = "0")] public class Estrato : ActiveRecordValidationBase { private int id; private EstratoType type; private QuestionContainer container; private Estrato parentEstrato; - private ISet subestratos = new ListSet(); - private ISet references = new ListSet(); + private ISet subestratos = new HashSet(); + private ISet references = new HashSet(); public Estrato() { @@ -46,7 +47,7 @@ public int Id set { id = value; } } - [Property("type", Insert=false, Update=false)] + [Property("type", Insert = false, Update = false)] public EstratoType EstratoType { get { return type; } @@ -60,22 +61,22 @@ public QuestionContainer Container set { container = value; } } - [HasAndBelongsToMany( typeof(Estrato), Table="EstratoRefEstrato", ColumnRef="ref_estrato_id", ColumnKey="estrato_id" )] - public ISet ReferencedEstratos + [HasAndBelongsToMany(typeof(Estrato), Table = "EstratoRefEstrato", ColumnRef = "ref_estrato_id", ColumnKey = "estrato_id")] + public ISet ReferencedEstratos { get { return references; } set { references = value; } } - [BelongsTo("parent_id", Type=typeof(Estrato))] + [BelongsTo("parent_id", Type = typeof(Estrato))] public Estrato ParentEstrato { get { return parentEstrato; } set { parentEstrato = value; } } - [HasMany( typeof(Estrato), Inverse=true, Cascade=ManyRelationCascadeEnum.All)] - public ISet SubEstratos + [HasMany(typeof(Estrato), Inverse = true, Cascade = ManyRelationCascadeEnum.All)] + public ISet SubEstratos { get { return subestratos; } set { subestratos = value; } diff --git a/src/Castle.ActiveRecord.Tests/Model/StrictModel/QuestionContainer.cs b/src/Castle.ActiveRecord.Tests/Model/StrictModel/QuestionContainer.cs index 5b2d08e..155e7da 100644 --- a/src/Castle.ActiveRecord.Tests/Model/StrictModel/QuestionContainer.cs +++ b/src/Castle.ActiveRecord.Tests/Model/StrictModel/QuestionContainer.cs @@ -15,6 +15,7 @@ namespace Castle.ActiveRecord.Tests.Model.StrictModel { using System; + using System.Collections.Generic; using Iesi.Collections; @@ -25,12 +26,12 @@ public enum ContainerType Survey } - [ActiveRecord(DiscriminatorColumn="type", DiscriminatorType="Int16", DiscriminatorValue="0")] + [ActiveRecord(DiscriminatorColumn = "type", DiscriminatorType = "Int16", DiscriminatorValue = "0")] public class QuestionContainer : ActiveRecordValidationBase { private int id; private ContainerType type; - private ISet estratos = new ListSet(); + private ISet estratos = new HashSet(); public QuestionContainer() { @@ -43,15 +44,15 @@ public int Id set { id = value; } } - [Property("type", Insert=false, Update=false)] + [Property("type", Insert = false, Update = false)] public ContainerType Type { get { return type; } set { type = value; } } - [HasMany( typeof(Estrato), Inverse=true)] - public ISet Estratos + [HasMany(typeof(Estrato), Inverse = true)] + public ISet Estratos { get { return estratos; } set { estratos = value; } @@ -59,12 +60,12 @@ public ISet Estratos public static void DeleteAll() { - ActiveRecordBase.DeleteAll( typeof(QuestionContainer) ); + ActiveRecordBase.DeleteAll(typeof(QuestionContainer)); } public static QuestionContainer Find(int id) { - return (QuestionContainer) ActiveRecordBase.FindByPrimaryKey( typeof(QuestionContainer), id ); + return (QuestionContainer)ActiveRecordBase.FindByPrimaryKey(typeof(QuestionContainer), id); } public override bool Equals(object obj) diff --git a/src/Castle.ActiveRecord.Tests/StatelessSessionScopeTestCase.cs b/src/Castle.ActiveRecord.Tests/StatelessSessionScopeTestCase.cs index 52d2b51..de30c8f 100644 --- a/src/Castle.ActiveRecord.Tests/StatelessSessionScopeTestCase.cs +++ b/src/Castle.ActiveRecord.Tests/StatelessSessionScopeTestCase.cs @@ -25,6 +25,8 @@ namespace Castle.ActiveRecord.Tests using NHibernate.Criterion; using NUnit.Framework; using System.Collections; + using System.Collections.Generic; + using Castle.ActiveRecord.Queries; [TestFixture] @@ -84,7 +86,7 @@ public void A_simple_object_can_be_read() using (new StatelessSessionScope()) { Assert.IsTrue(ActiveRecordMediator.Exists(1)); - Assert.AreEqual("Andrea Doria",ActiveRecordMediator.FindByPrimaryKey(1).Name); + Assert.AreEqual("Andrea Doria", ActiveRecordMediator.FindByPrimaryKey(1).Name); } } @@ -120,9 +122,9 @@ public void Get_with_nonlazy_classes_does_not_work() Blog.Find(1); Assert.Fail(); } - catch(ActiveRecordException ex) + catch (ActiveRecordException ex) { - Assert.AreEqual(typeof(SessionException),ex.InnerException.GetType()); + Assert.AreEqual(typeof(SessionException), ex.InnerException.GetType()); Assert.AreEqual("collections cannot be fetched by a stateless session", ex.InnerException.Message); } } @@ -134,7 +136,9 @@ public void Updating_stateless_fetched_entities_works() InitializeLazy(); using (new SessionScope()) + { CreateLazyBlog(); + } using (new StatelessSessionScope()) { @@ -208,11 +212,11 @@ public void Updating_detached_entities_collections_does_not_work() using (new StatelessSessionScope()) { - blog.Posts = new ArrayList(); + blog.Posts = new List(); for (int i = 0; i < 10; i++) { - var post = new Post() { Title = "Post" + i, Created = DateTime.Now}; + var post = new Post() { Title = "Post" + i, Created = DateTime.Now }; post.Create(); blog.Posts.Add(post); } diff --git a/src/Castle.ActiveRecord.Tests/TableHierarchyTestCase.cs b/src/Castle.ActiveRecord.Tests/TableHierarchyTestCase.cs index df434ca..1655ac8 100644 --- a/src/Castle.ActiveRecord.Tests/TableHierarchyTestCase.cs +++ b/src/Castle.ActiveRecord.Tests/TableHierarchyTestCase.cs @@ -16,6 +16,7 @@ namespace Castle.ActiveRecord.Tests { using System; using System.Collections; + using System.Collections.Generic; using NUnit.Framework; @@ -28,7 +29,7 @@ public class TableHierarchyTestCase : AbstractActiveRecordTest [Test] public void CompanyFirmAndClient() { - ActiveRecordStarter.Initialize( GetConfigSource(), + ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Company), typeof(Client), typeof(Firm), typeof(Person), typeof(Blog), typeof(Post)); Recreate(); @@ -45,22 +46,22 @@ public void CompanyFirmAndClient() client.Save(); Client[] clients = Client.FindAll(); - Assert.AreEqual( 1, clients.Length ); + Assert.AreEqual(1, clients.Length); Firm[] firms = Firm.FindAll(); - Assert.AreEqual( 1, firms.Length ); + Assert.AreEqual(1, firms.Length); - Assert.AreEqual( firm.Id, firms[0].Id ); - Assert.AreEqual( client.Id, clients[0].Id ); + Assert.AreEqual(firm.Id, firms[0].Id); + Assert.AreEqual(client.Id, clients[0].Id); - Assert.IsNotNull( clients[0].Firm ); - Assert.AreEqual( firm.Id, clients[0].Firm.Id ); + Assert.IsNotNull(clients[0].Firm); + Assert.AreEqual(firm.Id, clients[0].Firm.Id); } [Test] public void ManyToMany() { - ActiveRecordStarter.Initialize( GetConfigSource(), + ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Company), typeof(Client), typeof(Firm), typeof(Person), typeof(Blog), typeof(Post)); Recreate(); @@ -74,7 +75,7 @@ public void ManyToMany() Client client = new Client("castle", firm); Company company = new Company("vs"); - using(new SessionScope()) + using (new SessionScope()) { firm.Save(); client.Save(); @@ -83,54 +84,54 @@ public void ManyToMany() Person person = new Person(); person.Name = "hammett"; - person.Companies.Add( firm ); - person.Companies.Add( client ); - person.Companies.Add( company ); + person.Companies.Add(firm); + person.Companies.Add(client); + person.Companies.Add(company); person.Save(); } - company = Company.Find( company.Id ); - Assert.AreEqual(1, company.People.Count ); + company = Company.Find(company.Id); + Assert.AreEqual(1, company.People.Count); } - + [Test] public void ManyToManyUsingSet() { - ActiveRecordStarter.Initialize(GetConfigSource(), + ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Order), typeof(Product)/*, typeof(LineItem)*/); Recreate(); - + Order.DeleteAll(); Product.DeleteAll(); - + Order myOrder = new Order(); myOrder.OrderedDate = DateTime.Parse("05/09/2004"); Product coolGadget = new Product(); coolGadget.Name = "PSP"; coolGadget.Price = 250.39f; - + using (new SessionScope()) { coolGadget.Save(); - ISet products = new ListSet(); + ISet products = new HashSet(); products.Add(coolGadget); myOrder.Products = products; myOrder.Save(); } - + Order secondRef2Order = Order.Find(myOrder.ID); - Assert.IsFalse(secondRef2Order.Products.IsEmpty); - + Assert.IsFalse(secondRef2Order.Products.Count == 0); + Product secondRef2Product = Product.Find(coolGadget.ID); - Assert.AreEqual(1, secondRef2Product.Orders.Count); + Assert.AreEqual(1, secondRef2Product.Orders.Count); } [Test] [Ignore("Jira issue for NH team")] public void InvalidSessionCache() { - ActiveRecordStarter.Initialize( GetConfigSource(), - typeof(Company), typeof(Client), typeof(Firm), typeof(Person) ); + ActiveRecordStarter.Initialize(GetConfigSource(), + typeof(Company), typeof(Client), typeof(Firm), typeof(Person)); Recreate(); Company.DeleteAll(); @@ -142,27 +143,27 @@ public void InvalidSessionCache() Client client = new Client("castle", firm); Company company = new Company("vs"); - using(new SessionScope()) + using (new SessionScope()) { firm.Save(); client.Save(); company.Save(); } - using(new SessionScope()) + using (new SessionScope()) { try { - Client c = Client.Find( firm.Id ); + Client c = Client.Find(firm.Id); Assert.Fail("Exception was expected"); } - catch(Exception) + catch (Exception) { // Phew!! } - Firm firm2 = Firm.Find( firm.Id ); + Firm firm2 = Firm.Find(firm.Id); Assert.IsNotNull(firm2); } @@ -172,31 +173,33 @@ public void InvalidSessionCache() [Ignore("Create schema does not create all necessary tables for this test case")] public void ManyToManyUsingIDBag() { - ActiveRecordStarter.Initialize(GetConfigSource(), + ActiveRecordStarter.Initialize(GetConfigSource(), typeof(OrderWithIDBag), typeof(ProductWithIDBag)); Recreate(); - + OrderWithIDBag.DeleteAll(); ProductWithIDBag.DeleteAll(); - + OrderWithIDBag myOrder = new OrderWithIDBag(); myOrder.OrderedDate = new DateTime(2006, 12, 25); - ProductWithIDBag coolGadget = new ProductWithIDBag(); - coolGadget.Name = "Xbox 2"; - coolGadget.Price = 330.23f; - + ProductWithIDBag coolGadget = new ProductWithIDBag + { + Name = "Xbox 2", + Price = 330.23f + }; + using (new SessionScope()) { coolGadget.Save(); - IList products = new ArrayList(); + var products = new List(); products.Add(coolGadget); myOrder.Products = products; myOrder.Save(); } - + OrderWithIDBag secondRef2Order = OrderWithIDBag.Find(myOrder.ID); Assert.IsTrue(secondRef2Order.Products.Count > 0); - + ProductWithIDBag secondRef2Product = ProductWithIDBag.Find(coolGadget.ID); Assert.AreEqual(1, secondRef2Product.Orders.Count); } diff --git a/src/Castle.ActiveRecord.Tests/packages.config b/src/Castle.ActiveRecord.Tests/packages.config new file mode 100644 index 0000000..4c7fd8f --- /dev/null +++ b/src/Castle.ActiveRecord.Tests/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Castle.ActiveRecord.Web/Castle.ActiveRecord.Web.csproj b/src/Castle.ActiveRecord.Web/Castle.ActiveRecord.Web.csproj index de734ed..effca95 100644 --- a/src/Castle.ActiveRecord.Web/Castle.ActiveRecord.Web.csproj +++ b/src/Castle.ActiveRecord.Web/Castle.ActiveRecord.Web.csproj @@ -4,8 +4,9 @@ $(MSBuildProjectDirectory)\..\.. v4.0 Client - NET40-Debug + NET40-Debug AnyCPU + c107c0fb 8.0.30703 @@ -21,7 +22,7 @@ v4.0 - + bin\NET40-Debug\ true full @@ -38,12 +39,12 @@ v4.0 - + bin\NET40-Release\ pdbonly true TRACE;PHYSICALASSEMBLY DOTNET DOTNET40 CLIENTPROFILE - bin\NET40-Release\Castle.ActiveRecord.Web.xml + bin\NET40-Release\Castle.ActiveRecord.Web.xml prompt 4 1591 @@ -71,7 +72,7 @@ bin\NET35-Release\ TRACE;PHYSICALASSEMBLY DOTNET DOTNET35 - bin\NET40-Release\Castle.ActiveRecord.Web.xml + bin\NET40-Release\Castle.ActiveRecord.Web.xml true true 1591 @@ -83,11 +84,12 @@ ..\..\lib\$(BuildConfigKey)\Castle.Components.Validator.dll - - ..\..\lib\NHibernate.dll - + + ..\..\packages\System.Data.SQLite.Core.1.0.96.0\lib\net40\System.Data.SQLite.dll + True + @@ -101,18 +103,29 @@ + + + + + + + - {652F95D4-86E2-40B6-919D-CFC6E449386B} + {652f95d4-86e2-40b6-919d-cfc6e449386b} Castle.ActiveRecord-vs2010 - - - + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +