Commit 08f4ce3
Changed files (164)
build
product
client
boot
presentation
commons
infrastructure
cloning
debugging
filesystem
proxies
registries
infrastructure.thirdparty
castle
dynamicproxy
interceptors
windsor
configuration
infrastructure.thirdparty.log4net
testing
utility
build/lib/app/gorilla/gorilla.commons.infrastructure.dll
Binary file
build/lib/app/gorilla/gorilla.commons.infrastructure.thirdparty.dll
Binary file
build/lib/app/gorilla/gorilla.commons.infrastructure.thirdparty.log4net.dll
Binary file
build/lib/app/gorilla/gorilla.commons.utility.dll
Binary file
product/client/boot/boot.csproj
@@ -37,47 +37,47 @@
</Reference>
<Reference Include="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
</Reference>
<Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\castle\Castle.Core.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\castle\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
</Reference>
<Reference Include="gorilla.commons.infrastructure, Version=2009.10.21.739, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.dll</HintPath>
</Reference>
<Reference Include="gorilla.commons.infrastructure.thirdparty, Version=2009.10.21.739, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.thirdparty.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.thirdparty.dll</HintPath>
</Reference>
<Reference Include="gorilla.commons.infrastructure.thirdparty.log4net, Version=2009.10.21.739, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.thirdparty.log4net.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.thirdparty.log4net.dll</HintPath>
</Reference>
<Reference Include="gorilla.commons.utility, Version=2009.10.21.739, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\gorilla\gorilla.commons.utility.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\gorilla\gorilla.commons.utility.dll</HintPath>
</Reference>
<Reference Include="gorilla.testing, Version=2009.5.5.194, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\gorilla\gorilla.testing.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\gorilla\gorilla.testing.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=4.1.933.3, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\jetbrains\JetBrains.Annotations.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\jetbrains\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\log4net\log4net.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\log4net\log4net.dll</HintPath>
</Reference>
<Reference Include="MbUnit.Framework, Version=2.4.2.130, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\tools\mbunit\MbUnit.Framework.dll</HintPath>
+ <HintPath>..\..\..\build\tools\mbunit\MbUnit.Framework.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
@@ -87,12 +87,12 @@
</Reference>
<Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition, Version=2008.11.24.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\managed.extensibility.framework\System.ComponentModel.Composition.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\managed.extensibility.framework\System.ComponentModel.Composition.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -111,7 +111,7 @@
</Reference>
<Reference Include="WeifenLuo.WinFormsUI.Docking, Version=2.3.3392.19652, Culture=neutral, PublicKeyToken=b602bcfb76b4e90d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\dock.panel.suite\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\dock.panel.suite\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -239,4 +239,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
\ No newline at end of file
+</Project>
product/client/presentation/Core/CachingViewFactory.cs
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel;
using System.Linq;
-using Gorilla.Commons.Infrastructure.Logging;
using gorilla.commons.utility;
using momoney.presentation.views;
product/client/presentation/Presentation.csproj
@@ -37,39 +37,39 @@
</Reference>
<Reference Include="ActiveReports.Viewer6, Version=6.0.1797.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\active.reports\ActiveReports.Viewer6.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\active.reports\ActiveReports.Viewer6.dll</HintPath>
</Reference>
<Reference Include="ActiveReports6, Version=6.0.1797.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\active.reports\ActiveReports6.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\active.reports\ActiveReports6.dll</HintPath>
</Reference>
<Reference Include="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
</Reference>
<Reference Include="ComponentFactory.Krypton.Toolkit, Version=3.0.8.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\component.factory\ComponentFactory.Krypton.Toolkit.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\component.factory\ComponentFactory.Krypton.Toolkit.dll</HintPath>
</Reference>
<Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
</Reference>
<Reference Include="gorilla.commons.infrastructure, Version=2009.5.5.1633, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\gorilla\gorilla.commons.infrastructure.dll</HintPath>
</Reference>
<Reference Include="gorilla.commons.utility, Version=2009.5.5.1633, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\gorilla\gorilla.commons.utility.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\gorilla\gorilla.commons.utility.dll</HintPath>
</Reference>
<Reference Include="gorilla.testing, Version=2009.5.5.194, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\gorilla\gorilla.testing.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\gorilla\gorilla.testing.dll</HintPath>
</Reference>
<Reference Include="MbUnit.Framework, Version=2.4.2.175, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\mbunit\MbUnit.Framework.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\mbunit\MbUnit.Framework.dll</HintPath>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
@@ -79,12 +79,12 @@
</Reference>
<Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
+ <HintPath>..\..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition, Version=2009.1.23.0, Culture=neutral, PublicKeyToken=687787ccb6c36c9f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\managed.extensibility.framework\System.ComponentModel.Composition.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\managed.extensibility.framework\System.ComponentModel.Composition.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -104,14 +104,14 @@
</Reference>
<Reference Include="WeifenLuo.WinFormsUI.Docking, Version=2.3.3392.19652, Culture=neutral, PublicKeyToken=b602bcfb76b4e90d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\dock.panel.suite\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\dock.panel.suite\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="XPExplorerBar, Version=3.3.0.0, Culture=neutral, PublicKeyToken=26272737b5f33015">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\xp.explorer.bar\XPExplorerBar.dll</HintPath>
+ <HintPath>..\..\..\build\lib\app\xp.explorer.bar\XPExplorerBar.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -569,4 +569,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
\ No newline at end of file
+</Project>
product/commons/infrastructure/cloning/BinarySerializer.cs
@@ -0,0 +1,11 @@
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace Gorilla.Commons.Infrastructure.Cloning
+{
+ public class BinarySerializer<T> : FileStreamSerializer<T>
+ {
+ public BinarySerializer(string file_path) : base(file_path, new BinaryFormatter())
+ {
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/cloning/BinarySerializerSpecs.cs
@@ -0,0 +1,74 @@
+using System;
+using System.IO;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+using MbUnit.Framework;
+
+namespace Gorilla.Commons.Infrastructure.Cloning
+{
+ [Concern(typeof (BinarySerializer<TestItem>))]
+ public abstract class when_a_file_is_specified_to_serialize_an_item_to : concerns_for<Serializer<TestItem>, BinarySerializer<TestItem>>
+ {
+ public override Serializer<TestItem> create_sut()
+ {
+ return new BinarySerializer<TestItem>(file_name);
+ }
+
+ context c = () => { file_name = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "serialized.dat"); };
+
+ after_each_observation aeo = () => { if (File.Exists(file_name)) File.Delete(file_name); };
+
+ static protected string file_name;
+ }
+
+ [Concern(typeof (BinarySerializer<TestItem>))]
+ public class when_serializing_an_item : when_a_file_is_specified_to_serialize_an_item_to
+ {
+ it should_serialize_the_item_to_a_file = () => FileAssert.Exists(file_name);
+
+ because b = () => sut.serialize(new TestItem(string.Empty));
+ }
+
+ [Concern(typeof (BinarySerializer<TestItem>))]
+ public class when_deserializing_an_item : when_a_file_is_specified_to_serialize_an_item_to
+ {
+ it should_be_able_to_deserialize_from_a_serialized_file = () => result.should_be_equal_to(original);
+
+ context c = () => { original = new TestItem("hello world"); };
+
+ because b = () =>
+ {
+ sut.serialize(original);
+ result = sut.deserialize();
+ };
+
+ static TestItem original;
+ static TestItem result;
+ }
+
+ [Serializable]
+ public class TestItem : IEquatable<TestItem>
+ {
+ public TestItem(string text)
+ {
+ Text = text;
+ }
+
+ public string Text { get; set; }
+
+ public bool Equals(TestItem testItem)
+ {
+ return testItem != null;
+ }
+
+ public override bool Equals(object obj)
+ {
+ return ReferenceEquals(this, obj) || Equals(obj as TestItem);
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/cloning/FileStreamSerializer.cs
@@ -0,0 +1,34 @@
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace Gorilla.Commons.Infrastructure.Cloning
+{
+ public class FileStreamSerializer<T> : Serializer<T>
+ {
+ public FileStreamSerializer(string file_path, IFormatter formatter)
+ {
+ this.file_path = file_path;
+ this.formatter = formatter;
+ }
+
+ public void serialize(T to_serialize)
+ {
+ using (var stream = new FileStream(file_path, FileMode.Create, FileAccess.Write))
+ formatter.Serialize(stream, to_serialize);
+ }
+
+ public T deserialize()
+ {
+ using (var stream = new FileStream(file_path, FileMode.Open, FileAccess.Read))
+ return (T) formatter.Deserialize(stream);
+ }
+
+ public void Dispose()
+ {
+ File.Delete(file_path);
+ }
+
+ readonly string file_path;
+ readonly IFormatter formatter;
+ }
+}
\ No newline at end of file
product/commons/infrastructure/cloning/Prototype.cs
@@ -0,0 +1,21 @@
+using System.IO;
+
+namespace Gorilla.Commons.Infrastructure.Cloning
+{
+ public interface IPrototype
+ {
+ T clone<T>(T item);
+ }
+
+ public class Prototype : IPrototype
+ {
+ public T clone<T>(T item)
+ {
+ using (var serializer = new BinarySerializer<T>(Path.GetTempFileName()))
+ {
+ serializer.serialize(item);
+ return serializer.deserialize();
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/cloning/Serializer.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Cloning
+{
+ public interface Serializer<T> : IDisposable
+ {
+ void serialize(T to_serialize);
+ T deserialize();
+ }
+}
\ No newline at end of file
product/commons/infrastructure/container/DependencyRegistry.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+
+namespace Gorilla.Commons.Infrastructure.Container
+{
+ public interface DependencyRegistry
+ {
+ Contract get_a<Contract>();
+ IEnumerable<Contract> get_all<Contract>();
+ }
+}
\ No newline at end of file
product/commons/infrastructure/container/DependencyResolutionException.cs
@@ -0,0 +1,13 @@
+using System;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Container
+{
+ public class DependencyResolutionException<T> : Exception
+ {
+ public DependencyResolutionException(Exception inner_exception)
+ : base("Could not resolve {0}".formatted_using(typeof (T).FullName), inner_exception)
+ {
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/container/Resolve.cs
@@ -0,0 +1,33 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Container
+{
+ static public class Resolve
+ {
+ static DependencyRegistry underlying_registry;
+ static bool initialized;
+
+ static public void initialize_with(DependencyRegistry registry)
+ {
+ underlying_registry = registry;
+ initialized = registry != null;
+ }
+
+ static public DependencyToResolve the<DependencyToResolve>()
+ {
+ try
+ {
+ return underlying_registry.get_a<DependencyToResolve>();
+ }
+ catch (Exception e)
+ {
+ throw new DependencyResolutionException<DependencyToResolve>(e);
+ }
+ }
+
+ static public bool is_initialized()
+ {
+ return initialized;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/container/ResolveSpecs.cs
@@ -0,0 +1,58 @@
+using System;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Container
+{
+ [Concern(typeof (Resolve))]
+ public abstract class behaves_like_a_inversion_of_control_container : concerns
+ {
+ }
+
+ [Concern(typeof(Resolve))]
+ public class when_resolving_a_dependency_using_the_container : behaves_like_a_inversion_of_control_container
+ {
+ context c = () =>
+ {
+ registry = an<DependencyRegistry>();
+ presenter = an<Command>();
+ registry.is_told_to(x => x.get_a<Command>()).it_will_return(presenter);
+ Resolve.initialize_with(registry);
+ };
+
+ because b = () => { result = Resolve.the<Command>(); };
+
+ it should_leverage_the_underlying_container_it_was_initialized_with =
+ () => registry.was_told_to(x => x.get_a<Command>());
+
+ it should_return_the_resolved_dependency = () => result.should_be_equal_to(presenter);
+
+ after_each_observation a = () => Resolve.initialize_with(null);
+
+ static DependencyRegistry registry;
+ static Command result;
+ static Command presenter;
+ }
+
+ [Concern(typeof(Resolve))]
+ public class when_resolving_a_dependency_that_is_not_registered_ : behaves_like_a_inversion_of_control_container
+ {
+ context c = () =>
+ {
+ registry = an<DependencyRegistry>();
+ registry.is_told_to(x => x.get_a<Command>()).it_will_throw(new Exception());
+ Resolve.initialize_with(registry);
+ };
+
+ because b = () => { the_call = call.to(() => Resolve.the<Command>()); };
+
+ after_each_observation a = () => Resolve.initialize_with(null);
+
+ it should_throw_a_dependency_resolution_exception =
+ () => the_call.should_have_thrown<DependencyResolutionException<Command>>();
+
+ static DependencyRegistry registry;
+ static Action the_call;
+ }
+}
\ No newline at end of file
product/commons/infrastructure/debugging/Launch.cs
@@ -0,0 +1,15 @@
+using System.Diagnostics;
+
+namespace Gorilla.Commons.Infrastructure.Debugging
+{
+ static public class Launch
+ {
+ static public void the_debugger()
+ {
+#if DEBUG
+ if (Debugger.IsAttached) Debugger.Break();
+ else Debugger.Launch();
+#endif
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/filesystem/ApplicationFile.cs
@@ -0,0 +1,62 @@
+namespace Gorilla.Commons.Infrastructure.FileSystem
+{
+ public class ApplicationFile : File
+ {
+ public ApplicationFile(string path)
+ {
+ this.path = path;
+ }
+
+ public virtual string path { get; private set; }
+
+ public virtual bool does_the_file_exist()
+ {
+ return !string.IsNullOrEmpty(path) && System.IO.File.Exists(path);
+ }
+
+ public void copy_to(string other_path)
+ {
+ System.IO.File.Copy(path, other_path, true);
+ }
+
+ public void delete()
+ {
+ System.IO.File.Delete(path);
+ }
+
+ public static implicit operator ApplicationFile(string file_path)
+ {
+ return new ApplicationFile(file_path);
+ }
+
+ public static implicit operator string(ApplicationFile file)
+ {
+ return file.path;
+ }
+
+ public bool Equals(ApplicationFile other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(other.path, path);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (ApplicationFile)) return false;
+ return Equals((ApplicationFile) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (path != null ? path.GetHashCode() : 0);
+ }
+
+ public override string ToString()
+ {
+ return path;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/filesystem/File.cs
@@ -0,0 +1,10 @@
+namespace Gorilla.Commons.Infrastructure.FileSystem
+{
+ public interface File
+ {
+ string path { get; }
+ bool does_the_file_exist();
+ void copy_to(string path);
+ void delete();
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/Log.cs
@@ -0,0 +1,25 @@
+using System;
+using Gorilla.Commons.Infrastructure.Container;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ static public class Log
+ {
+ static public Logger For<T>(T item_to_create_logger_for)
+ {
+ return For(typeof (T));
+ }
+
+ static public Logger For(Type type_to_create_a_logger_for)
+ {
+ try
+ {
+ return Resolve.the<LogFactory>().create_for(type_to_create_a_logger_for);
+ }
+ catch
+ {
+ return new TextLogger(Console.Out);
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/LogFactory.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ public interface LogFactory
+ {
+ Logger create_for(Type type_to_create_logger_for);
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/Loggable.cs
@@ -0,0 +1,7 @@
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ public interface Loggable
+ {
+
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/Logger.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ public interface Logger
+ {
+ void informational(string formatted_string, params object[] arguments);
+ void debug(string formatted_string, params object[] arguments);
+ void error(Exception e);
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/LoggingExtensions.cs
@@ -0,0 +1,17 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ public static class LoggingExtensions
+ {
+ public static Logger log<T>(this T item_to_log)
+ {
+ return Log.For(item_to_log);
+ }
+
+ public static void add_to_log(this Exception error_to_log)
+ {
+ Log.For(error_to_log).error(error_to_log);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/LogSpecs.cs
@@ -0,0 +1,31 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Infrastructure.Container;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ [Concern(typeof (Log))]
+ public class when_creating_a_logger_for_a_particular_type_ : concerns
+ {
+ it should_return_the_logger_created_for_that_type = () => result.should_be_equal_to(logger);
+
+ context c =
+ () =>
+ {
+ var factory = an<LogFactory>();
+ var registry = an<DependencyRegistry>();
+ logger = an<Logger>();
+ registry.is_told_to(x => x.get_a<LogFactory>()).it_will_return(factory);
+ factory.is_told_to(x => x.create_for(typeof (string))).it_will_return(logger);
+
+ Resolve.initialize_with(registry);
+ };
+
+ because b = () => { result = Log.For("mo"); };
+
+ after_each_observation a = () => Resolve.initialize_with(null);
+
+ static Logger result;
+ static Logger logger;
+ }
+}
\ No newline at end of file
product/commons/infrastructure/logging/TextLogger.cs
@@ -0,0 +1,33 @@
+using System;
+using System.IO;
+using System.Threading;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Logging
+{
+ public class TextLogger : Logger
+ {
+ readonly TextWriter writer;
+
+ public TextLogger(TextWriter writer)
+ {
+ this.writer = writer;
+ }
+
+ public void informational(string formatted_string, params object[] arguments)
+ {
+ writer.WriteLine(formatted_string, arguments);
+ }
+
+ public void debug(string formatted_string, params object[] arguments)
+ {
+ writer.WriteLine("[{0}] - {1}", Thread.CurrentThread.ManagedThreadId,
+ formatted_string.formatted_using(arguments));
+ }
+
+ public void error(Exception e)
+ {
+ writer.WriteLine("{0}", e);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/ExceptionExtensions.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Reflection;
+
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ static public class ExceptionExtensions
+ {
+ static readonly MethodInfo method =
+ typeof (Exception).GetMethod("InternalPreserveStackTrace",
+ BindingFlags.NonPublic | BindingFlags.Instance);
+
+ static public Exception preserve_stack_trace(this Exception exception)
+ {
+ method.Invoke(exception, new object[0]);
+ return exception;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/Interceptor.cs
@@ -0,0 +1,7 @@
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ public interface Interceptor
+ {
+ void intercept(Invocation invocation);
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/Invocation.cs
@@ -0,0 +1,12 @@
+using System.Reflection;
+
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ public interface Invocation
+ {
+ void proceed();
+ object[] arguments { get; }
+ MethodInfo method { get; }
+ object return_value { get; set; }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/MethodCallInvocation.cs
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.Remoting.Messaging;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ public class MethodCallInvocation<T> : Invocation
+ {
+ readonly IMethodCallMessage call;
+ readonly T target;
+ readonly Stack<Interceptor> interceptors;
+
+ public MethodCallInvocation(IEnumerable<Interceptor> interceptors, IMethodCallMessage call, T target)
+ {
+ this.call = call;
+ this.target = target;
+ this.interceptors = new Stack<Interceptor>(interceptors);
+ arguments = call.Properties["__Args"].downcast_to<object[]>();
+ method = call.MethodBase.downcast_to<MethodInfo>();
+ }
+
+ public object[] arguments { get; set; }
+
+ public MethodInfo method { get; set; }
+
+ public object return_value { get; set; }
+
+ public void proceed()
+ {
+ if (interceptors.Count > 0)
+ {
+ interceptors.Pop().intercept(this);
+ return;
+ }
+
+ try
+ {
+ return_value = call.MethodBase.Invoke(target, arguments);
+ }
+ catch (TargetInvocationException e)
+ {
+ throw e.InnerException.preserve_stack_trace();
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/ProxyFactory.cs
@@ -0,0 +1,10 @@
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ static public class ProxyFactory
+ {
+ static public T create<T>(T target, params Interceptor[] interceptors)
+ {
+ return new RemotingProxyFactory<T>(target, interceptors).create_proxy();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/ProxyFactorySpecs.cs
@@ -0,0 +1,60 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ public class ProxyFactorySpecs
+ {
+ [Concern(typeof (ProxyFactory))]
+ public class when_proxying_a_class_with_interceptors_applied : concerns
+ {
+ context c = () =>
+ {
+ interceptors = new MyNameIsSlimShadyInterceptor();
+ marshal_mathers = new Person("marshall mathers");
+ };
+
+ because b =
+ () =>
+ {
+ some_celebrity = ProxyFactory.create<IPerson>(marshal_mathers, interceptors);
+ };
+
+ it should_all_each_interceptor_to_intercept_the_invocation =
+ () => some_celebrity.what_is_your_name().should_be_equal_to("slim shady");
+
+ static Person marshal_mathers;
+ static IPerson some_celebrity;
+ static Interceptor interceptors;
+ }
+
+ public interface IPerson
+ {
+ string what_is_your_name();
+ }
+
+ public class Person : IPerson
+ {
+ readonly string my_name;
+
+ public Person(string my_name)
+ {
+ this.my_name = my_name;
+ }
+
+ public string what_is_your_name()
+ {
+ return my_name;
+ }
+ }
+
+ public class MyNameIsSlimShadyInterceptor : Interceptor
+ {
+ public void intercept(Invocation invocation)
+ {
+ invocation.proceed();
+ invocation.return_value = "slim shady";
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/proxies/RemotingProxyFactory.cs
@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Proxies;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Proxies
+{
+ public class RemotingProxyFactory<T> : RealProxy
+ {
+ readonly T target;
+ readonly IEnumerable<Interceptor> interceptors;
+
+ public RemotingProxyFactory(T target, IEnumerable<Interceptor> interceptors) : base(typeof (T))
+ {
+ this.target = target;
+ this.interceptors = interceptors;
+ }
+
+ public override IMessage Invoke(IMessage message)
+ {
+ if (message.is_an_implementation_of<IMethodCallMessage>())
+ {
+ var call = message.downcast_to<IMethodCallMessage>();
+ var invocation = new MethodCallInvocation<T>(interceptors, call, target);
+ invocation.proceed();
+ return return_value(invocation.return_value, invocation.arguments, call);
+ }
+ return null;
+ }
+
+ IMessage return_value(object return_value, object[] out_parameters, IMethodCallMessage call)
+ {
+ return new ReturnMessage(return_value,
+ out_parameters,
+ out_parameters == null ? 0 : out_parameters.Length,
+ call.LogicalCallContext, call);
+ }
+
+ public T create_proxy()
+ {
+ return GetTransparentProxy().downcast_to<T>();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/reflection/ApplicationAssembly.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+namespace Gorilla.Commons.Infrastructure.Reflection
+{
+ public class ApplicationAssembly : Assembly
+ {
+ readonly System.Reflection.Assembly assembly;
+
+ public ApplicationAssembly(System.Reflection.Assembly assembly)
+ {
+ this.assembly = assembly;
+ }
+
+ public IEnumerable<Type> all_types()
+ {
+ return assembly.GetTypes();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/reflection/Assembly.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+
+namespace Gorilla.Commons.Infrastructure.Reflection
+{
+ public interface Assembly
+ {
+ IEnumerable<Type> all_types();
+ }
+}
\ No newline at end of file
product/commons/infrastructure/reflection/EnvironmentExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Gorilla.Commons.Infrastructure.Reflection
+{
+ public static class EnvironmentExtensions
+ {
+ public static string startup_directory<T>(this T item)
+ {
+ return AppDomain.CurrentDomain.BaseDirectory;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/registries/DefaultRegistry.cs
@@ -0,0 +1,32 @@
+using System.Collections;
+using System.Collections.Generic;
+using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Registries
+{
+ public class DefaultRegistry<T> : Registry<T>
+ {
+ readonly DependencyRegistry registry;
+
+ public DefaultRegistry(DependencyRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public IEnumerable<T> all()
+ {
+ return registry.get_all<T>();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return all().GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure/registries/DefaultRegistrySpecs.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Infrastructure.Container;
+using Gorilla.Commons.Testing;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Infrastructure.Registries
+{
+ [Concern(typeof (DefaultRegistry<int>))]
+ public class when_retrieving_all_the_items_from_the_default_repository :
+ concerns_for<Registry<int>, DefaultRegistry<int>>
+ {
+ it should_leverage_the_resolver_to_retrieve_all_the_implementations =
+ () => registry.was_told_to(r => r.get_all<int>());
+
+ it should_return_the_items_resolved_by_the_registry = () => result.should_contain(24);
+
+ context c = () =>
+ {
+ var items_to_return = new List<int> {24};
+ registry = an<DependencyRegistry>();
+ registry.is_told_to(r => r.get_all<int>()).it_will_return(items_to_return);
+ };
+
+ public override Registry<int> create_sut()
+ {
+ return new DefaultRegistry<int>(registry);
+ }
+
+ because b = () => { result = sut.all(); };
+
+ static DependencyRegistry registry;
+ static IEnumerable<int> result;
+ }
+}
\ No newline at end of file
product/commons/infrastructure/infrastructure.csproj
@@ -0,0 +1,117 @@
+๏ปฟ<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>gorilla.commons.infrastructure</RootNamespace>
+ <AssemblyName>gorilla.commons.infrastructure</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
+ </Reference>
+ <Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
+ </Reference>
+ <Reference Include="MbUnit.Framework, Version=2.4.2.175, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\mbunit\MbUnit.Framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="cloning\BinarySerializer.cs" />
+ <Compile Include="cloning\BinarySerializerSpecs.cs" />
+ <Compile Include="cloning\Serializer.cs" />
+ <Compile Include="cloning\Prototype.cs" />
+ <Compile Include="cloning\FileStreamSerializer.cs" />
+ <Compile Include="container\DependencyResolutionException.cs" />
+ <Compile Include="container\DependencyRegistry.cs" />
+ <Compile Include="container\Resolve.cs" />
+ <Compile Include="container\ResolveSpecs.cs" />
+ <Compile Include="debugging\Launch.cs" />
+ <Compile Include="filesystem\ApplicationFile.cs" />
+ <Compile Include="filesystem\File.cs" />
+ <Compile Include="logging\TextLogger.cs" />
+ <Compile Include="logging\LogFactory.cs" />
+ <Compile Include="logging\Loggable.cs" />
+ <Compile Include="logging\Logger.cs" />
+ <Compile Include="logging\Log.cs" />
+ <Compile Include="logging\LoggingExtensions.cs" />
+ <Compile Include="logging\LogSpecs.cs" />
+ <Compile Include="proxies\ExceptionExtensions.cs" />
+ <Compile Include="proxies\Interceptor.cs" />
+ <Compile Include="proxies\Invocation.cs" />
+ <Compile Include="proxies\MethodCallInvocation.cs" />
+ <Compile Include="proxies\ProxyFactory.cs" />
+ <Compile Include="proxies\ProxyFactorySpecs.cs" />
+ <Compile Include="proxies\RemotingProxyFactory.cs" />
+ <Compile Include="reflection\ApplicationAssembly.cs" />
+ <Compile Include="reflection\EnvironmentExtensions.cs" />
+ <Compile Include="reflection\Assembly.cs" />
+ <Compile Include="registries\DefaultRegistry.cs" />
+ <Compile Include="registries\DefaultRegistrySpecs.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\testing\test.helpers.csproj">
+ <Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
+ <Name>test.helpers</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\utility\utility.csproj">
+ <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
+ <Name>utility</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </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>
\ No newline at end of file
product/commons/infrastructure.thirdparty/autofac/AutofacDependencyRegistry.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using Autofac;
+using Gorilla.Commons.Infrastructure.Container;
+
+namespace gorilla.commons.infrastructure.thirdparty.autofac
+{
+ internal class AutofacDependencyRegistry : DependencyRegistry
+ {
+ readonly Func<IContainer> container;
+
+ public AutofacDependencyRegistry(Func<IContainer> container)
+ {
+ this.container = container;
+ }
+
+ public Interface get_a<Interface>()
+ {
+ return container().Resolve<Interface>();
+ }
+
+ public IEnumerable<Interface> get_all<Interface>()
+ {
+ return container().Resolve<IEnumerable<Interface>>();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/autofac/AutofacDependencyRegistryBuilder.cs
@@ -0,0 +1,71 @@
+using System;
+using Autofac;
+using Autofac.Builder;
+using Autofac.Modules;
+using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.autofac;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Autofac
+{
+ public class AutofacDependencyRegistryBuilder : DependencyRegistration
+ {
+ readonly ContainerBuilder builder;
+ readonly Func<IContainer> container;
+
+ public AutofacDependencyRegistryBuilder() : this(new ContainerBuilder())
+ {
+ }
+
+ public AutofacDependencyRegistryBuilder(ContainerBuilder builder)
+ {
+ this.builder = builder;
+ builder.RegisterModule(new ImplicitCollectionSupportModule());
+ builder.SetDefaultScope(InstanceScope.Factory);
+ container = () => builder.Build();
+ container = container.memorize();
+ }
+
+ public void singleton<Contract, Implementation>() where Implementation : Contract
+ {
+ builder.Register<Implementation>().As<Contract>().SingletonScoped();
+ }
+
+ public void singleton<Contract>(Func<Contract> instance_of_the_contract)
+ {
+ builder.Register(x => instance_of_the_contract()).As<Contract>().SingletonScoped();
+ }
+
+ public void transient<Contract, Implementation>() where Implementation : Contract
+ {
+ transient(typeof (Contract), typeof (Implementation));
+ }
+
+ public void transient(Type contract, Type implementation)
+ {
+ if (contract.is_a_generic_type())
+ builder.RegisterGeneric(implementation).As(contract).FactoryScoped();
+ else
+ builder.Register(implementation).As(contract).FactoryScoped();
+ }
+
+ public void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target)
+ {
+ var proxy_builder = new CastleDynamicProxyBuilder<T>();
+ configuration.configure(proxy_builder);
+ builder.Register(x => proxy_builder.create_proxy_for(target)).As<T>().FactoryScoped();
+ }
+
+ public void proxy<T, Configuration>(Func<T> target)
+ where Configuration : Configuration<ProxyBuilder<T>>, new()
+ {
+ proxy(new Configuration(), target);
+ }
+
+ public DependencyRegistry build()
+ {
+ return new AutofacDependencyRegistry(container);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/autofac/AutofacSpecs.cs
@@ -0,0 +1,71 @@
+using System.Collections.Generic;
+using System.Linq;
+using Autofac;
+using Autofac.Builder;
+using Autofac.Modules;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.autofac
+{
+ [Concern(typeof (ContainerBuilder))]
+ public class when_trying_to_register_a_single_item_in_the_autofac_container : concerns
+ {
+ it should_resolve_that_item = () => result.should_be_an_instance_of<A>();
+
+ context c = () =>
+ {
+ builder = new ContainerBuilder();
+ builder.Register<A>().As<ITestItem>().FactoryScoped();
+ container = builder.Build();
+ };
+
+ because b = () => { result = container.Resolve<ITestItem>(); };
+
+ after_each_observation after_each = () => container.Dispose();
+
+ static ContainerBuilder builder;
+ static IContainer container;
+ static ITestItem result;
+ }
+
+ [Concern(typeof (ContainerBuilder))]
+ public class when_trying_to_resolve_all_the_components_that_implement_a_common_interface : concerns
+ {
+ it should_return_each_component = () =>
+ {
+ results.Count().should_be_equal_to(2);
+ results.First().should_be_an_instance_of<A>();
+ results.Skip(1).First().should_be_an_instance_of<B>();
+ };
+
+ context c = () =>
+ {
+ builder = new ContainerBuilder();
+ builder.RegisterModule(new ImplicitCollectionSupportModule());
+ builder.Register<A>().As<ITestItem>().FactoryScoped();
+ builder.Register<B>().As<ITestItem>().FactoryScoped();
+ container = builder.Build();
+ };
+
+ because b = () => { results = container.Resolve<IEnumerable<ITestItem>>(); };
+
+ after_each_observation after_each = () => container.Dispose();
+
+ static ContainerBuilder builder;
+ static IContainer container;
+ static IEnumerable<ITestItem> results;
+ }
+
+ public interface ITestItem
+ {
+ }
+
+ public class A : ITestItem
+ {
+ }
+
+ public class B : ITestItem
+ {
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/interceptors/CastleDynamicMethodCallTracker.cs
@@ -0,0 +1,41 @@
+using System.Collections.Generic;
+using Castle.Core.Interceptor;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
+{
+ public class CastleDynamicMethodCallTracker<TypeToProxy> : MethodCallTracker<TypeToProxy>
+ {
+ readonly IList<string> the_name_of_each_method_to_intercept;
+
+ public CastleDynamicMethodCallTracker() : this(new List<string>())
+ {
+ }
+
+ public CastleDynamicMethodCallTracker(IList<string> the_name_of_each_method_to_intercept)
+ {
+ this.the_name_of_each_method_to_intercept = the_name_of_each_method_to_intercept;
+ }
+
+ public TypeToProxy target { get; set; }
+
+ public void Intercept(IInvocation invocation)
+ {
+ set_return_value_for(invocation);
+ if (the_name_of_each_method_to_intercept.Contains(invocation.Method.Name)) return;
+ the_name_of_each_method_to_intercept.Add(invocation.Method.Name);
+ }
+
+ public IEnumerable<string> methods_to_intercept()
+ {
+ return the_name_of_each_method_to_intercept;
+ }
+
+ static void set_return_value_for(IInvocation invocation)
+ {
+ var return_type = invocation.Method.ReturnType;
+ if (return_type == typeof (void)) return;
+ invocation.ReturnValue = return_type.default_value();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/interceptors/MethodCallTracker.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Castle.Core.Interceptor;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
+{
+ public interface MethodCallTracker<TypeToProxy> : IInterceptor
+ {
+ TypeToProxy target { get; }
+ IEnumerable<string> methods_to_intercept();
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/interceptors/MethodCallTrackerSpecs.cs
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using System.Linq;
+using Castle.Core.Interceptor;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
+{
+ [Concern(typeof (CastleDynamicMethodCallTracker<>))]
+ public class behaves_like_method_call_tracker :
+ concerns_for<MethodCallTracker<IAnInterface>, CastleDynamicMethodCallTracker<IAnInterface>>
+ {
+ public override MethodCallTracker<IAnInterface> create_sut()
+ {
+ return new CastleDynamicMethodCallTracker<IAnInterface>();
+ }
+ }
+
+ [Concern(typeof (CastleDynamicMethodCallTracker<>))]
+ public class when_tracking_the_calls_to_intercept_on_a_type : behaves_like_method_call_tracker
+ {
+ static IInvocation invocation;
+ static IEnumerable<string> result;
+
+ context c = () =>
+ {
+ invocation = an<IInvocation>();
+ invocation
+ .is_told_to(s => s.Method)
+ .it_will_return(typeof (IAnInterface).GetMethod("ValueReturningMethodWithAnArgument"));
+ };
+
+ because b = () =>
+ {
+ sut.Intercept(invocation);
+ result = sut.methods_to_intercept();
+ };
+
+ it should_return_all_the_methods_that_are_specified_for_interception =
+ () => result.should_contain(typeof (IAnInterface).GetMethod("ValueReturningMethodWithAnArgument").Name);
+
+ it should_only_contain_the_methods_specified_for_interception = () => result.Count().should_be_equal_to(1);
+
+ it should_specify_the_default_return_value_for_the_method_to_intercept =
+ //() => invocation.was_told_to(i => i.ReturnValue = 0);
+ () => invocation.ReturnValue.should_be_equal_to(0);
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/interceptors/SelectiveInterceptor.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Castle.Core.Interceptor;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors
+{
+ public class SelectiveInterceptor : IInterceptor
+ {
+ private readonly IList<string> methods_to_intercept;
+ private readonly IInterceptor underlying_interceptor;
+
+ public SelectiveInterceptor(IEnumerable<string> methods_to_intercept, IInterceptor underlying_interceptor)
+ {
+ this.methods_to_intercept = new List<string>(methods_to_intercept);
+ this.underlying_interceptor = underlying_interceptor;
+ }
+
+ public void Intercept(IInvocation invocation)
+ {
+ if (methods_to_intercept.Contains(invocation.Method.Name))
+ {
+ underlying_interceptor.Intercept(invocation);
+ return;
+ }
+ invocation.Proceed();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/interceptors/SynchronizeInvokeInterceptor.cs
@@ -0,0 +1,25 @@
+using System;
+using System.ComponentModel;
+using Castle.Core.Interceptor;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.castle.dynamicproxy.interceptors
+{
+ public interface SynchronizedInterceptor : IInterceptor
+ {
+ }
+
+ public class SynchronizeInvokeInterceptor<T> : SynchronizedInterceptor where T : ISynchronizeInvoke
+ {
+ public void Intercept(IInvocation invocation)
+ {
+ var target = invocation.InvocationTarget.downcast_to<T>();
+ target.BeginInvoke(do_it(invocation.Proceed), new object[] {});
+ }
+
+ Delegate do_it(Action action)
+ {
+ return action;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/CastleDynamicInterceptorConstraint.cs
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicInterceptorConstraint<TypeToPutConstraintOn> : InterceptorConstraint<TypeToPutConstraintOn>
+ {
+ readonly MethodCallTracker<TypeToPutConstraintOn> call_tracker;
+ bool intercept_all_calls;
+
+ public CastleDynamicInterceptorConstraint(MethodCallTracker<TypeToPutConstraintOn> call_tracker)
+ {
+ this.call_tracker = call_tracker;
+ }
+
+ public TypeToPutConstraintOn intercept_on
+ {
+ get { return call_tracker.target; }
+ }
+
+ public void intercept_all()
+ {
+ intercept_all_calls = true;
+ }
+
+ public IEnumerable<string> methods_to_intercept()
+ {
+ return intercept_all_calls ? gell_all_methods() : call_tracker.methods_to_intercept();
+ }
+
+ IEnumerable<string> gell_all_methods()
+ {
+ return all_methods().Select(x => x.Name);
+ }
+
+ IEnumerable<MethodInfo> all_methods()
+ {
+ return typeof (TypeToPutConstraintOn).GetMethods(BindingFlags.Public | BindingFlags.Instance);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/CastleDynamicInterceptorConstraintFactory.cs
@@ -0,0 +1,21 @@
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicInterceptorConstraintFactory : InterceptorConstraintFactory
+ {
+ readonly MethodCallTrackerFactory factory;
+
+ public CastleDynamicInterceptorConstraintFactory() : this(new CastleDynamicMethodCallTrackerFactory())
+ {
+ }
+
+ public CastleDynamicInterceptorConstraintFactory(MethodCallTrackerFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ public InterceptorConstraint<Type> CreateFor<Type>()
+ {
+ return new CastleDynamicInterceptorConstraint<Type>(factory.create_for<Type>());
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/CastleDynamicMethodCallTrackerFactory.cs
@@ -0,0 +1,27 @@
+using Castle.DynamicProxy;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicMethodCallTrackerFactory : MethodCallTrackerFactory
+ {
+ private readonly ProxyGenerator generator;
+
+ public CastleDynamicMethodCallTrackerFactory() : this(new ProxyGenerator())
+ {
+ }
+
+ public CastleDynamicMethodCallTrackerFactory(ProxyGenerator generator)
+ {
+ this.generator = generator;
+ }
+
+ public MethodCallTracker<TypeToProxy> create_for<TypeToProxy>()
+ {
+ var call_tracker_interceptor = new CastleDynamicMethodCallTracker<TypeToProxy>();
+ var target = generator.CreateInterfaceProxyWithoutTarget<TypeToProxy>(call_tracker_interceptor);
+ call_tracker_interceptor.target = target;
+ return call_tracker_interceptor;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/CastleDynamicProxyBuilder.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Castle.Core.Interceptor;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicProxyBuilder<TypeToProxy> : ProxyBuilder<TypeToProxy>
+ {
+ readonly IDictionary<IInterceptor, InterceptorConstraint<TypeToProxy>> constraints;
+ readonly ProxyFactory proxy_factory;
+ readonly InterceptorConstraintFactory constraint_factory;
+
+ public CastleDynamicProxyBuilder() : this(new CastleDynamicProxyFactory(), new CastleDynamicInterceptorConstraintFactory())
+ {
+ }
+
+ public CastleDynamicProxyBuilder(ProxyFactory proxy_factory, InterceptorConstraintFactory constraint_factory)
+ {
+ this.proxy_factory = proxy_factory;
+ this.constraint_factory = constraint_factory;
+ constraints = new Dictionary<IInterceptor, InterceptorConstraint<TypeToProxy>>();
+ }
+
+ public ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>(Interceptor interceptor)
+ where Interceptor : IInterceptor
+ {
+ var constraint = constraint_factory.CreateFor<TypeToProxy>();
+ constraints.Add(interceptor, constraint);
+ return constraint;
+ }
+
+ public ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>() where Interceptor : IInterceptor, new()
+ {
+ return add_interceptor(new Interceptor());
+ }
+
+ public TypeToProxy create_proxy_for(TypeToProxy target)
+ {
+ return create_proxy_for(() => target);
+ }
+
+ public TypeToProxy create_proxy_for(Func<TypeToProxy> target)
+ {
+ return proxy_factory.create_proxy_for(target, all_interceptors_with_their_constraints().ToArray());
+ }
+
+ IEnumerable<IInterceptor> all_interceptors_with_their_constraints()
+ {
+ foreach (var pair in constraints)
+ {
+ var constraint = pair.Value;
+ var interceptor = pair.Key;
+ if (constraint.methods_to_intercept().Count() > 0)
+ {
+ yield return new SelectiveInterceptor(constraint.methods_to_intercept(), interceptor);
+ }
+ else
+ {
+ yield return interceptor;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/CastleDynamicProxyFactory.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Castle.Core.Interceptor;
+using Castle.DynamicProxy;
+using gorilla.commons.infrastructure.thirdparty.castle.dynamicproxy;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class CastleDynamicProxyFactory : ProxyFactory
+ {
+ readonly ProxyGenerator generator;
+
+ public CastleDynamicProxyFactory() : this(new ProxyGenerator())
+ {
+ }
+
+ public CastleDynamicProxyFactory(ProxyGenerator generator)
+ {
+ this.generator = generator;
+ }
+
+ public TypeToProxy create_proxy_for<TypeToProxy>(Func<TypeToProxy> implementation, params IInterceptor[] interceptors)
+ {
+ return create_proxy_for(lazy_load(implementation), interceptors);
+ }
+
+ T lazy_load<T>(Func<T> implementation)
+ {
+ if (typeof (T).IsInterface)
+ {
+ return generator.CreateInterfaceProxyWithoutTarget<T>(new LazyLoadedInterceptor<T>(implementation));
+ }
+ return generator.CreateClassProxy<T>(new LazyLoadedInterceptor<T>(implementation));
+ }
+
+ TypeToProxy create_proxy_for<TypeToProxy>(TypeToProxy implementation,
+ IEnumerable<IInterceptor> interceptors)
+ {
+ if (typeof (TypeToProxy).IsInterface)
+ {
+ return generator.CreateInterfaceProxyWithTarget<TypeToProxy>(implementation, interceptors.ToArray());
+ }
+ var list = interceptors.ToList();
+ list.Add(new LazyLoadedInterceptor<TypeToProxy>(() => implementation));
+ return generator.CreateClassProxy<TypeToProxy>(list.ToArray());
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/ConstraintSelector.cs
@@ -0,0 +1,8 @@
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public interface ConstraintSelector<TypeToPutConstraintOn>
+ {
+ TypeToPutConstraintOn intercept_on { get; }
+ void intercept_all();
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/InterceptorConstraint.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public interface InterceptorConstraint<TypeToPutConstraintOn> : ConstraintSelector<TypeToPutConstraintOn>
+ {
+ IEnumerable<string> methods_to_intercept();
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/InterceptorConstraintFactory.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public interface InterceptorConstraintFactory
+ {
+ InterceptorConstraint<Type> CreateFor<Type>();
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/InterceptorConstraintFactorySpecs.cs
@@ -0,0 +1,28 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ [Concern(typeof (CastleDynamicInterceptorConstraintFactory))]
+ public abstract class behaves_like_constraint_factory :
+ concerns_for<InterceptorConstraintFactory, CastleDynamicInterceptorConstraintFactory>
+ {
+ context c = () => { method_call_tracker_factory = the_dependency<MethodCallTrackerFactory>(); };
+
+ protected static MethodCallTrackerFactory method_call_tracker_factory;
+ }
+
+ [Concern(typeof (CastleDynamicInterceptorConstraintFactory))]
+ public class when_creating_a_constraint_for_a_type_to_intercept_on : behaves_like_constraint_factory
+ {
+ static InterceptorConstraint<string> result;
+
+ it should_create_a_method_call_tracker_for_the_type_to_place_a_constraint_on =
+ () => method_call_tracker_factory.was_told_to(f => f.create_for<string>());
+
+ it should_return_an_instance_of_an_interceptor_constraint =
+ () => result.should_be_an_instance_of<CastleDynamicInterceptorConstraint<string>>();
+
+ because b = () => { result = sut.CreateFor<string>(); };
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/InterceptorConstraintSpecs.cs
@@ -0,0 +1,55 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ [Concern(typeof (CastleDynamicInterceptorConstraint<>))]
+ public abstract class behaves_like_constraint : concerns_for<InterceptorConstraint<string>, CastleDynamicInterceptorConstraint<string>>
+ {
+ context c = () => { method_call_tracker = the_dependency<MethodCallTracker<string>>(); };
+
+ protected static MethodCallTracker<string> method_call_tracker;
+ }
+
+ [Concern(typeof (CastleDynamicInterceptorConstraint<>))]
+ public class when_asking_for_all_the_methods_to_intercept : behaves_like_constraint
+ {
+ static IEnumerable<string> result;
+ static IList<string> methods_to_intercept;
+
+ it should_return_all_the_recorded_method_calls_from_the_call_tracker =
+ () => result.should_be_equal_to(methods_to_intercept);
+
+ context c = () =>
+ {
+ methods_to_intercept = new List<string>();
+ method_call_tracker
+ .is_told_to(t => t.methods_to_intercept())
+ .it_will_return(methods_to_intercept);
+ };
+
+ because b = () => { result = sut.methods_to_intercept(); };
+ }
+
+ [Concern(typeof (CastleDynamicInterceptorConstraint<int>))]
+ public class when_asking_for_the_target_of_the_interception_constrain :
+ concerns_for<InterceptorConstraint<int>, CastleDynamicInterceptorConstraint<int>>
+ {
+ static MethodCallTracker<int> method_call_tracker;
+ static int result;
+ const int target_of_interception = 7;
+
+ context c = () =>
+ {
+ method_call_tracker = the_dependency<MethodCallTracker<int>>();
+ method_call_tracker.is_told_to(t => t.target).it_will_return(target_of_interception);
+ };
+
+ because b = () => { result = sut.intercept_on; };
+
+ it should_return_the_target_of_the_method_call_tracker =
+ () => result.should_be_equal_to(target_of_interception);
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/Lazy.cs
@@ -0,0 +1,28 @@
+using System;
+using Castle.Core.Interceptor;
+using Castle.DynamicProxy;
+using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.castle.dynamicproxy;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public static class Lazy
+ {
+ public static T load<T>() where T : class
+ {
+ return create_proxy_for<T>(create_interceptor_for<T>());
+ }
+
+ static IInterceptor create_interceptor_for<T>() where T : class
+ {
+ Func<T> get_the_implementation = Resolve.the<T>;
+ return new LazyLoadedInterceptor<T>(get_the_implementation.memorize());
+ }
+
+ static T create_proxy_for<T>(IInterceptor interceptor)
+ {
+ return new ProxyGenerator().CreateInterfaceProxyWithoutTarget<T>(interceptor);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/LazyLoadedInterceptor.cs
@@ -0,0 +1,21 @@
+using System;
+using Castle.Core.Interceptor;
+
+namespace gorilla.commons.infrastructure.thirdparty.castle.dynamicproxy
+{
+ internal class LazyLoadedInterceptor<T> : IInterceptor
+ {
+ private readonly Func<T> get_the_implementation;
+
+ public LazyLoadedInterceptor(Func<T> get_the_implementation)
+ {
+ this.get_the_implementation = get_the_implementation;
+ }
+
+ public void Intercept(IInvocation invocation)
+ {
+ var method = invocation.GetConcreteMethodInvocationTarget();
+ invocation.ReturnValue = method.Invoke(get_the_implementation(), invocation.Arguments);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/LazySpecs.cs
@@ -0,0 +1,200 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Infrastructure.Container;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public class LazySpecs
+ {
+ [Concern(typeof (Lazy))]
+ public abstract class behaves_like_a_lazy_loaded_object : concerns
+ {
+ context c = () =>
+ {
+ test_container = dependency<DependencyRegistry>();
+ Resolve.initialize_with(test_container);
+ };
+
+ after_each_observation a = () => Resolve.initialize_with(null);
+
+ static protected DependencyRegistry test_container;
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_calling_a_method_with_no_arguments_on_a_lazy_loaded_proxy : behaves_like_a_lazy_loaded_object
+ {
+ it should_forward_the_original_call_to_the_target = () => target.was_told_to(t => t.OneMethod());
+
+ context c = () =>
+ {
+ target = an<ITargetObject>();
+ test_container.is_told_to(t => t.get_a<ITargetObject>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var result = Lazy.load<ITargetObject>();
+ result.OneMethod();
+ };
+
+ static ITargetObject target;
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_calling_a_method_that_returns_an_argument_on_a_lazy_loaded_proxy :
+ behaves_like_a_lazy_loaded_object
+ {
+ it should_return_the_value_from_the_actual_target = () => result.should_be_equal_to(10);
+
+ context c = () =>
+ {
+ var target = an<ITargetObject>();
+
+ target.is_told_to(x => x.FirstValueReturningMethod()).it_will_return(10);
+ test_container.is_told_to(t => t.get_a<ITargetObject>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var proxy = Lazy.load<ITargetObject>();
+ result = proxy.FirstValueReturningMethod();
+ };
+
+ static int result;
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_calling_different_methods_on_an_proxied_object : behaves_like_a_lazy_loaded_object
+ {
+ it should_only_load_the_object_once =
+ () => test_container.was_told_to(x => x.get_a<ITargetObject>()).only_once();
+
+ context c = () =>
+ {
+ var target = an<ITargetObject>();
+ test_container.is_told_to(t => t.get_a<ITargetObject>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var proxy = Lazy.load<ITargetObject>();
+ proxy.SecondMethod();
+ proxy.FirstValueReturningMethod();
+ };
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_calling_a_method_that_takes_in_a_single_input_parameter_on_a_proxied_object :
+ behaves_like_a_lazy_loaded_object
+ {
+ it should_forward_the_call_to_the_original_target =
+ () => target.was_told_to(x => x.ValueReturningMethodWithAnArgument(88));
+
+ it should_return_the_correct_result = () => result.should_be_equal_to(99);
+
+ context c = () =>
+ {
+ target = an<ITargetObject>();
+
+ target.is_told_to(x => x.ValueReturningMethodWithAnArgument(88)).it_will_return(99);
+ test_container.is_told_to(t => t.get_a<ITargetObject>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var proxy = Lazy.load<ITargetObject>();
+ result = proxy.ValueReturningMethodWithAnArgument(88);
+ };
+
+ static ITargetObject target;
+ static int result;
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_accessing_the_value_of_a_property_on_a_proxied_object : behaves_like_a_lazy_loaded_object
+ {
+ it should_return_the_correct_value = () => result.should_be_equal_to("mo");
+
+ context c = () =>
+ {
+ var target = an<ITargetObject>();
+
+ target.GetterAndSetterProperty = "mo";
+ test_container.is_told_to(t => t.get_a<ITargetObject>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var proxy = Lazy.load<ITargetObject>();
+ result = proxy.GetterAndSetterProperty;
+ };
+
+ static string result;
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_setting_the_value_of_a_property_on_a_proxied_object : behaves_like_a_lazy_loaded_object
+ {
+ it should_set_the_value_on_the_original_target =
+ () => target.was_told_to(x => x.GetterAndSetterProperty = "khan");
+
+ context c = () =>
+ {
+ target = dependency<ITargetObject>();
+ test_container.is_told_to(t => t.get_a<ITargetObject>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var proxy = Lazy.load<ITargetObject>();
+ proxy.GetterAndSetterProperty = "khan";
+ };
+
+ static ITargetObject target;
+ }
+
+ [Concern(typeof (Lazy))]
+ public class when_calling_a_generic_method_on_a_proxied_object : behaves_like_a_lazy_loaded_object
+ {
+ it should_forward_the_call_to_the_target =
+ () => target.was_told_to(x => x.ValueReturningMethodWithAnArgument("blah"));
+
+ it should_return_the_correct_result = () => result.should_be_equal_to("hooray");
+
+ context c = () =>
+ {
+ target = an<IGenericInterface<string>>();
+
+ target.is_told_to(x => x.ValueReturningMethodWithAnArgument("blah")).it_will_return("hooray");
+ test_container.is_told_to(t => t.get_a<IGenericInterface<string>>()).it_will_return(target).Repeat.Once();
+ };
+
+ because b = () =>
+ {
+ var proxy = Lazy.load<IGenericInterface<string>>();
+ result = proxy.ValueReturningMethodWithAnArgument("blah");
+ };
+
+ static IGenericInterface<string> target;
+ static string result;
+ }
+
+ public interface IGenericInterface<T>
+ {
+ T GetterAndSetterProperty { get; set; }
+ void OneMethod();
+ void SecondMethod();
+ T FirstValueReturningMethod();
+ T ValueReturningMethodWithAnArgument(T item);
+ }
+
+ public interface ITargetObject
+ {
+ string GetterAndSetterProperty { get; set; }
+ void OneMethod();
+ void SecondMethod();
+ int FirstValueReturningMethod();
+ int ValueReturningMethodWithAnArgument(int number);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/MethodCallTrackerFactory.cs
@@ -0,0 +1,9 @@
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy.Interceptors;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public interface MethodCallTrackerFactory
+ {
+ MethodCallTracker<TypeToProxy> create_for<TypeToProxy>();
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/ProxyBuilder.cs
@@ -0,0 +1,15 @@
+using System;
+using Castle.Core.Interceptor;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public interface ProxyBuilder<TypeToProxy>
+ {
+ ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>(Interceptor interceptor)
+ where Interceptor : IInterceptor;
+
+ ConstraintSelector<TypeToProxy> add_interceptor<Interceptor>() where Interceptor : IInterceptor, new();
+ TypeToProxy create_proxy_for(TypeToProxy target);
+ TypeToProxy create_proxy_for(Func<TypeToProxy> target);
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/ProxyBuilderSpecs.cs
@@ -0,0 +1,207 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Castle.Core.Interceptor;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
+ public abstract class behaves_like_proxy_builder : concerns_for<ProxyBuilder<IAnInterface>, CastleDynamicProxyBuilder<IAnInterface>>
+ {
+ public override ProxyBuilder<IAnInterface> create_sut()
+ {
+ return new CastleDynamicProxyBuilder<IAnInterface>();
+ }
+ }
+
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
+ public class when_building_a_proxy_for_a_type : behaves_like_proxy_builder
+ {
+ it should_make_sure_the_original_call_gets_forwarded_to_the_item_to_proxy =
+ () =>
+ {
+ an_implementation_of_the_interface.was_told_to(i => i.OneMethod());
+ an_implementation_of_the_interface.was_told_to(i => i.SecondMethod());
+ };
+
+ it should_allow_each_intercepter_to_intercept_the_call =
+ () =>
+ {
+ SomeInterceptor.MethodsCalled.Count().should_be_equal_to(2);
+ AnotherInterceptor.MethodsCalled.Count().should_be_equal_to(2);
+ };
+
+ context c = () => { an_implementation_of_the_interface = an<IAnInterface>(); };
+
+ because b = () =>
+ {
+ sut.add_interceptor<SomeInterceptor>();
+ sut.add_interceptor<AnotherInterceptor>();
+ var proxy = sut.create_proxy_for(() => an_implementation_of_the_interface);
+ proxy.OneMethod();
+ proxy.SecondMethod();
+ };
+
+ after_each_observation ae = () =>
+ {
+ SomeInterceptor.Cleanup();
+ AnotherInterceptor.Cleanup();
+ };
+
+ static IAnInterface an_implementation_of_the_interface;
+ }
+
+ [Integration]
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
+ public class when_building_a_proxy_to_target_certain_methods_on_a_type : behaves_like_proxy_builder
+ {
+ it should_only_intercept_calls_on_the_method_that_was_specified =
+ () =>
+ {
+ SomeInterceptor.MethodsCalled.Count().should_be_equal_to(1);
+ SomeInterceptor.MethodsCalled.First().Name.should_be_equal_to("OneMethod");
+ };
+
+ context c = () => { an_implementation = an<IAnInterface>(); };
+
+ because b = () =>
+ {
+ var constraint = sut.add_interceptor<SomeInterceptor>();
+ constraint.intercept_on.OneMethod();
+
+ var proxy = sut.create_proxy_for(() => an_implementation);
+ proxy.OneMethod();
+ proxy.SecondMethod();
+ };
+
+ after_each_observation ae = () =>
+ {
+ SomeInterceptor.Cleanup();
+ AnotherInterceptor.Cleanup();
+ };
+
+ static IAnInterface an_implementation;
+ }
+
+ [Concern(typeof (CastleDynamicProxyBuilder<>))]
+ public class when_proxying_all_calls_on_a_target : behaves_like_proxy_builder
+ {
+ it should_intercept_each_call =
+ () =>
+ {
+ SomeInterceptor.MethodsCalled.Count().should_be_equal_to(3 );
+ SomeInterceptor.MethodsCalled.First().Name.should_be_equal_to("OneMethod");
+ SomeInterceptor.MethodsCalled.Skip(1).First().Name.should_be_equal_to("SecondMethod");
+ SomeInterceptor.MethodsCalled.Skip(2).First().Name.should_be_equal_to("region");
+ };
+
+ context c = () => { an_implementation = an<IAnInterface>(); };
+
+ because b = () =>
+ {
+ var constraint = sut.add_interceptor<SomeInterceptor>();
+ constraint.intercept_all();
+
+ var proxy = sut.create_proxy_for(() => an_implementation);
+ proxy.OneMethod();
+ proxy.SecondMethod();
+ proxy.region(() => "mo");
+ };
+
+ after_each_observation ae = () =>
+ {
+ SomeInterceptor.Cleanup();
+ AnotherInterceptor.Cleanup();
+ };
+
+ static IAnInterface an_implementation;
+ }
+
+ public interface IAnInterface
+ {
+ string GetterAndSetterProperty { get; set; }
+ void OneMethod();
+ void SecondMethod();
+ int FirstValueReturningMethod();
+ int ValueReturningMethodWithAnArgument(int number);
+ void region<T>(Func<T> call);
+ }
+
+ public class SomeInterceptor : IInterceptor
+ {
+ public static bool WasCalled;
+ public static IList<MethodInfo> MethodsCalled;
+
+ static SomeInterceptor()
+ {
+ MethodsCalled = new List<MethodInfo>();
+ }
+
+ public void Intercept(IInvocation invocation)
+ {
+ WasCalled = true;
+ MethodsCalled.Add(invocation.Method);
+ invocation.Proceed();
+ }
+
+ public static void Cleanup()
+ {
+ WasCalled = false;
+ MethodsCalled.Clear();
+ }
+ }
+
+ public class AnotherInterceptor : IInterceptor
+ {
+ public static bool WasCalled;
+ public static IList<MethodInfo> MethodsCalled;
+
+ static AnotherInterceptor()
+ {
+ MethodsCalled = new List<MethodInfo>();
+ }
+
+ public void Intercept(IInvocation invocation)
+ {
+ WasCalled = true;
+ MethodsCalled.Add(invocation.Method);
+ invocation.Proceed();
+ }
+
+ public static void Cleanup()
+ {
+ WasCalled = false;
+ MethodsCalled.Clear();
+ }
+ }
+
+ public class SomeImplementation : IAnInterface
+ {
+ public string GetterAndSetterProperty { get; set; }
+
+ public void OneMethod()
+ {
+ }
+
+ public void SecondMethod()
+ {
+ }
+
+ public int FirstValueReturningMethod()
+ {
+ return 1;
+ }
+
+ public int ValueReturningMethodWithAnArgument(int number)
+ {
+ return number + 1;
+ }
+
+ public void region<T>(Func<T> call)
+ {
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/ProxyFactory.cs
@@ -0,0 +1,10 @@
+using System;
+using Castle.Core.Interceptor;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ public interface ProxyFactory
+ {
+ TypeToProxy create_proxy_for<TypeToProxy>(Func<TypeToProxy> implementation, params IInterceptor[] interceptors);
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/dynamicproxy/ProxyFactorySpecs.cs
@@ -0,0 +1,107 @@
+using System;
+using System.Data;
+using Castle.Core.Interceptor;
+using developwithpassion.bdd.contexts;
+using developwithpassion.bdd.mbunit;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy
+{
+ [Concern(typeof(CastleDynamicProxyFactory))]
+ public abstract class behaves_like_proxy_factory : concerns_for<ProxyFactory, CastleDynamicProxyFactory>
+ {
+ public override ProxyFactory create_sut()
+ {
+ return new CastleDynamicProxyFactory();
+ }
+ }
+
+ [Concern(typeof(CastleDynamicProxyFactory))]
+ public class when_creating_a_proxy_with_a_target : behaves_like_proxy_factory
+ {
+ it should_forward_all_calls_to_the_target = () => target.was_told_to(x => x.Open());
+
+ it should_return_a_proxy_to_the_target = () =>
+ {
+ AssertionExtensions.should_not_be_null(result);
+ result.GetType().should_not_be_equal_to(target.GetType());
+ };
+
+ it should_allow_the_interceptors_to_intercept_all_calls =
+ () => AssertionExtensions.should_be_true(interceptor.recieved_call);
+
+ context c = () => { target = the_dependency<IDbConnection>(); };
+
+ because b = () =>
+ {
+ interceptor = new TestInterceptor();
+ result = sut.create_proxy_for(() => target, interceptor);
+ result.Open();
+ };
+
+ static IDbConnection target;
+ static IDbConnection result;
+ static TestInterceptor interceptor;
+ }
+
+ [Concern(typeof(CastleDynamicProxyFactory))]
+ public class when_creating_a_proxy_of_a_target_but_a_call_has_not_been_made_to_the_proxy_yet :
+ behaves_like_proxy_factory
+ {
+ it should_not_create_an_instance_of_the_target = () => AssertionExtensions.should_be_false(TestClass.was_created);
+
+ context c = TestClass.reset;
+
+ because b = () => { result = sut.create_proxy_for<IDisposable>(() => new TestClass()); };
+
+ after_each_observation ae = TestClass.reset;
+
+ static IDisposable result;
+ }
+
+ [Concern(typeof(CastleDynamicProxyFactory))]
+ public class when_creating_a_proxy_of_a_component_that_does_not_implement_an_interface : behaves_like_proxy_factory
+ {
+ it should_return_a_proxy = () => AssertionExtensions.should_not_be_null(result);
+
+ because b = () => { result = sut.create_proxy_for(() => new ClassWithNoInterface()); };
+
+ after_each_observation ae = TestClass.reset;
+
+ static ClassWithNoInterface result;
+ }
+
+ public class ClassWithNoInterface
+ {
+ }
+
+ public class TestClass : IDisposable
+ {
+ public static bool was_created;
+
+ public TestClass()
+ {
+ was_created = true;
+ }
+
+ public static void reset()
+ {
+ was_created = false;
+ }
+
+ public void Dispose()
+ {
+ }
+ }
+
+ public class TestInterceptor : IInterceptor
+ {
+ public bool recieved_call { get; set; }
+
+ public void Intercept(IInvocation invocation)
+ {
+ recieved_call = true;
+ invocation.Proceed();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/ApplyLoggingInterceptor.cs
@@ -0,0 +1,21 @@
+using Castle.Core;
+using Castle.MicroKernel.Registration;
+using Gorilla.Commons.Infrastructure.Logging;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public class ApplyLoggingInterceptor : RegistrationConfiguration
+ {
+ public void configure(ComponentRegistration registration)
+ {
+ var implementation = registration.Implementation;
+ if (typeof (Loggable).IsAssignableFrom(implementation))
+ {
+ registration
+ .Interceptors(new InterceptorReference(typeof (LoggingInterceptor)))
+ .First
+ .If((k, m) => true);
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/ComponentExclusionSpecification.cs
@@ -0,0 +1,9 @@
+using System;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public interface ComponentExclusionSpecification : Specification<Type>
+ {
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/ComponentRegistrationConfiguration.cs
@@ -0,0 +1,16 @@
+using Castle.MicroKernel.Registration;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public class ComponentRegistrationConfiguration : RegistrationConfiguration
+ {
+ public void configure(ComponentRegistration registration)
+ {
+ new RegisterComponentContract()
+ .then(new ConfigureComponentLifestyle()).then(new ApplyLoggingInterceptor())
+ //.then(new LogComponent())
+ .configure(registration);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/ConfigureComponentLifestyle.cs
@@ -0,0 +1,18 @@
+using Castle.Core;
+using Castle.MicroKernel.Registration;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public class ConfigureComponentLifestyle : RegistrationConfiguration
+ {
+ public void configure(ComponentRegistration registration)
+ {
+ var implementation = registration.Implementation;
+ if (implementation.GetCustomAttributes(typeof (SingletonAttribute), false).Length > 0)
+ {
+ registration.LifeStyle.Is(LifestyleType.Singleton);
+ }
+ registration.LifeStyle.Is(LifestyleType.Transient);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/LogComponent.cs
@@ -0,0 +1,12 @@
+using Castle.MicroKernel.Registration;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public class LogComponent : RegistrationConfiguration
+ {
+ public void configure(ComponentRegistration registration)
+ {
+ var implementation = registration.Implementation;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/LogEverythingInterceptor.cs
@@ -0,0 +1,18 @@
+using System.Diagnostics;
+using Castle.Core.Interceptor;
+using Gorilla.Commons.Infrastructure.Logging;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public class LogEverythingInterceptor : LoggingInterceptor
+ {
+ public void Intercept(IInvocation invocation)
+ {
+ var stopwatch = new Stopwatch();
+ stopwatch.Start();
+ invocation.Proceed();
+ stopwatch.Stop();
+ this.log().debug("{0}.{1} took {2}", invocation.TargetType.Name, invocation.Method.Name, stopwatch.Elapsed);
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/LoggingInterceptor.cs
@@ -0,0 +1,8 @@
+using Castle.Core.Interceptor;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public interface LoggingInterceptor : IInterceptor
+ {
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/RegisterComponentContract.cs
@@ -0,0 +1,16 @@
+using Castle.MicroKernel.Registration;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public class RegisterComponentContract : RegistrationConfiguration
+ {
+ public void configure(ComponentRegistration registration)
+ {
+ var implementation = registration.Implementation;
+ if (implementation.GetInterfaces().Length == 0)
+ {
+ registration.For(implementation);
+ }
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/configuration/RegistrationConfiguration.cs
@@ -0,0 +1,9 @@
+using Castle.MicroKernel.Registration;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor.Configuration
+{
+ public interface RegistrationConfiguration : Configuration<ComponentRegistration>
+ {
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/WindsorContainerFactory.cs
@@ -0,0 +1,13 @@
+using Castle.Windsor;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor
+{
+ public class WindsorContainerFactory : Factory<IWindsorContainer>
+ {
+ public IWindsorContainer create()
+ {
+ return new WindsorContainer();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/WindsorDependencyRegistry.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using Castle.Core;
+using Castle.Windsor;
+using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor
+{
+ public class WindsorDependencyRegistry : DependencyRegistration, DependencyRegistry
+ {
+ readonly IWindsorContainer underlying_container;
+
+ public WindsorDependencyRegistry(IWindsorContainer container)
+ {
+ underlying_container = container;
+ }
+
+ public Interface get_a<Interface>()
+ {
+ return underlying_container.Resolve<Interface>();
+ //return underlying_container.Kernel.Resolve<Interface>();
+ }
+
+ public IEnumerable<Interface> get_all<Interface>()
+ {
+ return underlying_container.ResolveAll<Interface>();
+ }
+
+ public void singleton<Interface, Implementation>() where Implementation : Interface
+ {
+ var interface_type = typeof (Interface);
+ var implementation_type = typeof (Implementation);
+ underlying_container.AddComponent(create_a_key_using(interface_type, implementation_type), interface_type,
+ implementation_type);
+ }
+
+ public void singleton<Contract>(Func<Contract> instance_of_the_contract)
+ {
+ underlying_container.Kernel.AddComponentInstance<Contract>(instance_of_the_contract());
+ }
+
+ public void transient<Interface, Implementation>() where Implementation : Interface
+ {
+ transient(typeof (Interface), typeof (Implementation));
+ }
+
+ public void transient(Type contract, Type implementation)
+ {
+ underlying_container.AddComponentLifeStyle(
+ create_a_key_using(contract, implementation),
+ contract, implementation, LifestyleType.Transient);
+ }
+
+ string create_a_key_using(Type interface_type, Type implementation_type)
+ {
+ return "{0}-{1}".formatted_using(interface_type.FullName, implementation_type.FullName);
+ }
+
+ public void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target)
+ {
+ var builder = new CastleDynamicProxyBuilder<T>();
+ configuration.configure(builder);
+ singleton(() => builder.create_proxy_for(target));
+ }
+
+ public void proxy<T, Configuration>(Func<T> target)
+ where Configuration : Configuration<ProxyBuilder<T>>, new()
+ {
+ proxy(new Configuration(), target);
+ }
+
+ public DependencyRegistry build()
+ {
+ return this;
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/WindsorDependencyRegistrySpecs.cs
@@ -0,0 +1,44 @@
+using Castle.Core;
+using Castle.Windsor;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Infrastructure.Container;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.infrastructure.thirdparty.Castle.Windsor
+{
+ [Concern(typeof (WindsorDependencyRegistry))]
+ public abstract class behaves_like_windsor_dependency_registry : concerns_for<DependencyRegistry, WindsorDependencyRegistry>
+ {
+ }
+
+ [Concern(typeof (WindsorDependencyRegistry))]
+ public class when_registering_a_singleton_component_with_the_windsor_container :
+ behaves_like_windsor_dependency_registry
+ {
+ it should_return_the_same_instance_each_time_its_resolved =
+ () => result.should_be_the_same_instance_as(sut.get_a<IBird>());
+
+ it should_not_return_null = () => result.should_not_be_null();
+
+ context c = () =>
+ {
+ var container = the_dependency<IWindsorContainer>();
+ var bird = new BlueBird();
+ container.is_told_to(x => x.Resolve<IBird>()).it_will_return(bird).Repeat.Any();
+ };
+
+ because b = () => { result = sut.get_a<IBird>(); };
+
+
+ static IBird result;
+ }
+
+ [Singleton]
+ public class BlueBird : IBird
+ {
+ }
+
+ public interface IBird
+ {
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/castle/windsor/WindsorExtensions.cs
@@ -0,0 +1,20 @@
+using System;
+using Castle.MicroKernel.Registration;
+
+namespace gorilla.commons.infrastructure.thirdparty.castle.windsor
+{
+ public static class WindsorExtensions
+ {
+ public static BasedOnDescriptor LastInterface(this ServiceDescriptor descriptor)
+ {
+ return descriptor.Select((type, base_type) =>
+ {
+ Type first = null;
+ var interfaces = type.GetInterfaces();
+ if (interfaces.Length > 0) first = interfaces[0];
+
+ return (first != null) ? new[] {first} : null;
+ });
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/DependencyRegistration.cs
@@ -0,0 +1,17 @@
+using System;
+using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.Castle.DynamicProxy;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.infrastructure.thirdparty
+{
+ public interface DependencyRegistration : Builder<DependencyRegistry>
+ {
+ void singleton<Contract, Implementation>() where Implementation : Contract;
+ void singleton<Contract>(Func<Contract> instance_of_the_contract);
+ void transient<Contract, Implementation>() where Implementation : Contract;
+ void transient(Type contract, Type implementation);
+ void proxy<T>(Configuration<ProxyBuilder<T>> configuration, Func<T> target);
+ void proxy<T, Configuration>(Func<T> target) where Configuration : Configuration<ProxyBuilder<T>>, new();
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/infrastructure.thirdparty.csproj
@@ -0,0 +1,158 @@
+๏ปฟ<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>gorilla.commons.infrastructure.thirdparty</RootNamespace>
+ <AssemblyName>gorilla.commons.infrastructure.thirdparty</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\auto.fac\Autofac.dll</HintPath>
+ </Reference>
+ <Reference Include="AutofacContrib.DynamicProxy2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\auto.fac.contrib\AutofacContrib.DynamicProxy2.dll</HintPath>
+ </Reference>
+ <Reference Include="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\castle\Castle.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.DynamicProxy2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\castle\Castle.DynamicProxy2.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\castle\Castle.MicroKernel.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\castle\Castle.Windsor.dll</HintPath>
+ </Reference>
+ <Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
+ </Reference>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\log4net\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="MbUnit.Framework, Version=2.4.2.175, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\mbunit\MbUnit.Framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="autofac\AutofacDependencyRegistry.cs" />
+ <Compile Include="autofac\AutofacDependencyRegistryBuilder.cs" />
+ <Compile Include="autofac\AutofacSpecs.cs" />
+ <Compile Include="castle\dynamicproxy\CastleDynamicInterceptorConstraint.cs" />
+ <Compile Include="castle\dynamicproxy\CastleDynamicInterceptorConstraintFactory.cs" />
+ <Compile Include="castle\dynamicproxy\interceptors\SynchronizeInvokeInterceptor.cs" />
+ <Compile Include="castle\dynamicproxy\CastleDynamicMethodCallTrackerFactory.cs" />
+ <Compile Include="castle\windsor\configuration\RegistrationConfiguration.cs" />
+ <Compile Include="castle\windsor\configuration\LoggingInterceptor.cs" />
+ <Compile Include="castle\windsor\WindsorExtensions.cs" />
+ <Compile Include="DependencyRegistration.cs" />
+ <Compile Include="castle\dynamicproxy\ConstraintSelector.cs" />
+ <Compile Include="castle\dynamicproxy\InterceptorConstraint.cs" />
+ <Compile Include="castle\dynamicproxy\InterceptorConstraintFactory.cs" />
+ <Compile Include="castle\dynamicproxy\MethodCallTrackerFactory.cs" />
+ <Compile Include="castle\dynamicproxy\InterceptorConstraintFactorySpecs.cs" />
+ <Compile Include="castle\dynamicproxy\InterceptorConstraintSpecs.cs" />
+ <Compile Include="castle\dynamicproxy\interceptors\MethodCallTracker.cs" />
+ <Compile Include="castle\dynamicproxy\interceptors\CastleDynamicMethodCallTracker.cs" />
+ <Compile Include="castle\dynamicproxy\interceptors\MethodCallTrackerSpecs.cs" />
+ <Compile Include="castle\dynamicproxy\interceptors\SelectiveInterceptor.cs" />
+ <Compile Include="castle\dynamicproxy\ProxyBuilder.cs" />
+ <Compile Include="castle\dynamicproxy\ProxyFactory.cs" />
+ <Compile Include="castle\dynamicproxy\Lazy.cs" />
+ <Compile Include="castle\dynamicproxy\LazyLoadedInterceptor.cs" />
+ <Compile Include="castle\dynamicproxy\LazySpecs.cs" />
+ <Compile Include="castle\dynamicproxy\CastleDynamicProxyBuilder.cs" />
+ <Compile Include="castle\dynamicproxy\ProxyBuilderSpecs.cs" />
+ <Compile Include="castle\dynamicproxy\CastleDynamicProxyFactory.cs" />
+ <Compile Include="castle\dynamicproxy\ProxyFactorySpecs.cs" />
+ <Compile Include="castle\windsor\configuration\ApplyLoggingInterceptor.cs" />
+ <Compile Include="castle\windsor\configuration\ComponentRegistrationConfiguration.cs" />
+ <Compile Include="castle\windsor\configuration\ConfigureComponentLifestyle.cs" />
+ <Compile Include="castle\windsor\configuration\ComponentExclusionSpecification.cs" />
+ <Compile Include="castle\windsor\configuration\LogComponent.cs" />
+ <Compile Include="castle\windsor\configuration\LogEverythingInterceptor.cs" />
+ <Compile Include="castle\windsor\configuration\RegisterComponentContract.cs" />
+ <Compile Include="castle\windsor\WindsorContainerFactory.cs" />
+ <Compile Include="castle\windsor\WindsorDependencyRegistry.cs" />
+ <Compile Include="castle\windsor\WindsorDependencyRegistrySpecs.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\infrastructure\infrastructure.csproj">
+ <Project>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</Project>
+ <Name>infrastructure</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\testing\test.helpers.csproj">
+ <Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
+ <Name>test.helpers</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\utility\utility.csproj">
+ <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
+ <Name>utility</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </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>
\ No newline at end of file
product/commons/infrastructure.thirdparty.log4net/infrastructure.thirdparty.log4net.csproj
@@ -0,0 +1,72 @@
+๏ปฟ<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>gorilla.commons.infrastructure.thirdparty.log4net</RootNamespace>
+ <AssemblyName>gorilla.commons.infrastructure.thirdparty.log4net</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\log4net\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Log4NetLogFactory.cs" />
+ <Compile Include="Log4NetLogger.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\infrastructure\infrastructure.csproj">
+ <Project>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</Project>
+ <Name>infrastructure</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </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>
product/commons/infrastructure.thirdparty.log4net/Log4NetLogFactory.cs
@@ -0,0 +1,27 @@
+using System;
+using System.IO;
+using Gorilla.Commons.Infrastructure.Logging;
+using Gorilla.Commons.Infrastructure.Reflection;
+using log4net;
+using log4net.Config;
+
+namespace gorilla.commons.infrastructure.thirdparty.Log4Net
+{
+ public class Log4NetLogFactory : LogFactory
+ {
+ public Log4NetLogFactory()
+ {
+ XmlConfigurator.Configure(PathToConfigFile());
+ }
+
+ public Logger create_for(Type type_to_create_logger_for)
+ {
+ return new Log4NetLogger(LogManager.GetLogger(type_to_create_logger_for));
+ }
+
+ FileInfo PathToConfigFile()
+ {
+ return new FileInfo(Path.Combine(this.startup_directory(), "log4net.config.xml"));
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty.log4net/Log4NetLogger.cs
@@ -0,0 +1,31 @@
+using System;
+using Gorilla.Commons.Infrastructure.Logging;
+using log4net;
+
+namespace gorilla.commons.infrastructure.thirdparty.Log4Net
+{
+ public class Log4NetLogger : Logger
+ {
+ readonly ILog log;
+
+ public Log4NetLogger(ILog log)
+ {
+ this.log = log;
+ }
+
+ public void informational(string formatted_string, params object[] arguments)
+ {
+ log.InfoFormat(formatted_string, arguments);
+ }
+
+ public void debug(string formatted_string, params object[] arguments)
+ {
+ log.DebugFormat(formatted_string, arguments);
+ }
+
+ public void error(Exception e)
+ {
+ log.Error(e.ToString());
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/assertions.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using JetBrains.Annotations;
+using MbUnit.Framework;
+
+namespace Gorilla.Commons.Testing
+{
+ public static class Assertions
+ {
+ [AssertionMethod]
+ public static void should_be_equal_to<T>(this T item_to_validate, T expected_value)
+ {
+ Assert.AreEqual(expected_value, item_to_validate);
+ }
+
+ [AssertionMethod]
+ public static void should_be_the_same_instance_as<T>(this T left, T right)
+ {
+ Assert.IsTrue(ReferenceEquals(left, right));
+ }
+
+ [AssertionMethod]
+ public static void should_be_null<T>(this T item)
+ {
+ Assert.IsNull(item);
+ }
+
+ [AssertionMethod]
+ public static void should_not_be_null<T>(this T item) where T : class
+ {
+ Assert.IsNotNull(item);
+ }
+
+ [AssertionMethod]
+ public static void should_be_greater_than<T>(this T actual, T expected) where T : IComparable
+ {
+ Assert.GreaterThan(actual, expected);
+ }
+
+ [AssertionMethod]
+ public static void should_be_less_than(this int actual, int expected)
+ {
+ Assert.Less(actual, expected);
+ }
+
+ [AssertionMethod]
+ public static void should_contain<T>(this IEnumerable<T> items_to_peek_in_to, T items_to_look_for)
+ {
+ items_to_peek_in_to.Contains(items_to_look_for).should_be_true();
+ }
+
+ [AssertionMethod]
+ public static void should_not_contain<T>(this IEnumerable<T> items_to_peek_into, T item_to_look_for)
+ {
+ items_to_peek_into.Contains(item_to_look_for).should_be_false();
+ }
+
+ [AssertionMethod]
+ public static void should_be_an_instance_of<T>(this object item)
+ {
+ item.should_be_an_instance_of(typeof (T));
+ }
+
+ [AssertionMethod]
+ public static void should_be_an_instance_of(this object item, Type type)
+ {
+ Assert.IsInstanceOfType(type, item);
+ }
+
+ [AssertionMethod]
+ public static void should_have_thrown<TheException>(this Action action) where TheException : Exception
+ {
+ try
+ {
+ action();
+ Assert.Fail("the_exception_was_not_thrown");
+ }
+ catch (Exception e)
+ {
+ should_be_an_instance_of<TheException>(e);
+ }
+ }
+
+ [AssertionMethod]
+ public static void should_be_true(this bool item)
+ {
+ Assert.IsTrue(item);
+ }
+
+ [AssertionMethod]
+ public static void should_be_false(this bool item)
+ {
+ Assert.IsFalse(item);
+ }
+
+ [AssertionMethod]
+ public static void should_contain<T>(this IEnumerable<T> items, params T[] items_to_find)
+ {
+ foreach (var item_to_find in items_to_find)
+ {
+ items.should_contain(item_to_find);
+ }
+ }
+
+ [AssertionMethod]
+ public static void should_only_contain<T>(this IEnumerable<T> items, params T[] itemsToFind)
+ {
+ items.Count().should_be_equal_to(itemsToFind.Length);
+ items.should_contain(itemsToFind);
+ }
+
+ [AssertionMethod]
+ public static void should_be_equal_ignoring_case(this string item, string other)
+ {
+ StringAssert.AreEqualIgnoreCase(item, other);
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/Call.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Gorilla.Commons.Testing
+{
+ public class call
+ {
+ public static Action to(Action action)
+ {
+ return action;
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/ConcernAttribute.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace Gorilla.Commons.Testing
+{
+ public class ConcernAttribute : bdddoc.core.ConcernAttribute
+ {
+ public ConcernAttribute(Type concern) : base(concern)
+ {
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/concerns.cs
@@ -0,0 +1,42 @@
+using developwithpassion.bdd.mbunit.standard.observations;
+using Rhino.Mocks;
+
+namespace Gorilla.Commons.Testing
+{
+ public abstract class concerns_for<Contract> : observations_for_a_sut_without_a_contract<Contract>,
+ IHideObjectMembers
+ {
+ protected static T when_the<T>(T item)
+ {
+ return item;
+ }
+ }
+
+ public abstract class concerns_for<Contract, Implementation> :
+ observations_for_a_sut_with_a_contract<Contract, Implementation>, IHideObjectMembers
+ where Implementation : Contract
+ {
+ protected static T when_the<T>(T item)
+ {
+ return item;
+ }
+
+ protected static T dependency<T>() where T : class
+ {
+ return MockRepository.GenerateMock<T>();
+ }
+ }
+
+ public abstract class concerns : observations_for_a_static_sut, IHideObjectMembers
+ {
+ protected static T dependency<T>() where T : class
+ {
+ return MockRepository.GenerateMock<T>();
+ }
+
+ static protected T when_the<T>(T item)
+ {
+ return item;
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/EmptyFixture.cs
@@ -0,0 +1,9 @@
+using MbUnit.Framework;
+
+namespace Gorilla.Commons.Testing
+{
+ [TestFixture]
+ public class EmptyFixture
+ {
+ }
+}
\ No newline at end of file
product/commons/testing/IHideObjectMembers.cs
@@ -0,0 +1,21 @@
+using System;
+using System.ComponentModel;
+
+namespace Gorilla.Commons.Testing
+{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface IHideObjectMembers
+ {
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Type GetType();
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ int GetHashCode();
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ string ToString();
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ bool Equals(object obj);
+ }
+}
\ No newline at end of file
product/commons/testing/IntegrationAttribute.cs
@@ -0,0 +1,11 @@
+using MbUnit.Framework;
+
+namespace Gorilla.Commons.Testing
+{
+ public class IntegrationAttribute : FixtureCategoryAttribute
+ {
+ public IntegrationAttribute() : base("Integration")
+ {
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/MethodCallOccurance.cs
@@ -0,0 +1,33 @@
+using System;
+using Rhino.Mocks;
+
+namespace Gorilla.Commons.Testing
+{
+ public class MethodCallOccurance<T> : IHideObjectMembers
+ {
+ readonly Action<T> action;
+ readonly T mock;
+
+ public MethodCallOccurance(T mock, Action<T> action)
+ {
+ this.action = action;
+ this.mock = mock;
+ mock.AssertWasCalled(action);
+ }
+
+ public void times(int number_of_times_the_method_should_have_been_called)
+ {
+ mock.AssertWasCalled(action, y => y.Repeat.Times(number_of_times_the_method_should_have_been_called));
+ }
+
+ public void only_once()
+ {
+ times(1);
+ }
+
+ public void twice()
+ {
+ times(2);
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/MockingExtensions.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Rhino.Mocks;
+using Rhino.Mocks.Interfaces;
+
+namespace Gorilla.Commons.Testing
+{
+ public static class MockingExtensions
+ {
+ public static MethodCallOccurance<T> was_told_to<T>(this T mocked_item, Action<T> action_to_perform)
+ {
+ return new MethodCallOccurance<T>(mocked_item, action_to_perform);
+ }
+
+ public static void was_not_told_to<T>(this T mocked_item, Action<T> action_to_perform)
+ {
+ mocked_item.AssertWasNotCalled(action_to_perform);
+ }
+
+ public static IMethodOptions<R> is_told_to<T, R>(this T mocked_item, Function<T, R> action_to_perform) where T : class
+ {
+ return mocked_item.Stub(action_to_perform);
+ }
+
+ public static IMethodOptions<R> is_asked_for<T, R>(this T mock, Function<T, R> func) where T : class
+ {
+ return mock.Stub(func);
+ }
+
+ public static IMethodOptions<R> it_will_return<R>(this IMethodOptions<R> options, R item)
+ {
+ return options.Return(item);
+ }
+
+ public static IMethodOptions<IEnumerable<R>> it_will_return<R>(this IMethodOptions<IEnumerable<R>> options,
+ params R[] items)
+ {
+ return options.Return(items.AsEnumerable());
+ }
+
+ public static IMethodOptions<IEnumerable<R>> it_will_return_nothing<R>(
+ this IMethodOptions<IEnumerable<R>> options)
+ {
+ return options.it_will_return();
+ }
+
+ public static void it_will_throw<R>(this IMethodOptions<R> options, Exception item)
+ {
+ options.Throw(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/testing/test.helpers.csproj
@@ -0,0 +1,89 @@
+๏ปฟ<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{44E65096-9657-4716-90F8-4535BABE8039}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>gorilla.commons.testing</RootNamespace>
+ <AssemblyName>gorilla.commons.testing</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
+ </Reference>
+ <Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
+ </Reference>
+ <Reference Include="JetBrains.Annotations, Version=4.5.1181.216, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\jetbrains\JetBrains.Annotations.dll</HintPath>
+ </Reference>
+ <Reference Include="MbUnit.Framework, Version=2.4.2.175, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\mbunit\MbUnit.Framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Call.cs" />
+ <Compile Include="ConcernAttribute.cs" />
+ <Compile Include="IntegrationAttribute.cs" />
+ <Compile Include="concerns.cs" />
+ <Compile Include="assertions.cs" />
+ <Compile Include="EmptyFixture.cs" />
+ <Compile Include="IHideObjectMembers.cs" />
+ <Compile Include="MethodCallOccurance.cs" />
+ <Compile Include="MockingExtensions.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </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>
product/commons/utility/AndSpecification.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class AndSpecification<T> : Specification<T>
+ {
+ readonly Specification<T> left;
+ readonly Specification<T> right;
+
+ public AndSpecification(Specification<T> left, Specification<T> right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return left.is_satisfied_by(item) && right.is_satisfied_by(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/AnonymousCommand.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Linq.Expressions;
+
+namespace gorilla.commons.utility
+{
+ public class AnonymousCommand : Command
+ {
+ readonly Action action;
+
+ public AnonymousCommand(Expression<Action> action) : this(action.Compile()) {}
+
+ public AnonymousCommand(Action action)
+ {
+ this.action = action;
+ }
+
+ public void run()
+ {
+ action();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/AnonymousDisposable.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ public class AnonymousDisposable : IDisposable
+ {
+ readonly Action action;
+
+ public AnonymousDisposable(Action action)
+ {
+ this.action = action;
+ }
+
+ public void Dispose()
+ {
+ action();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/AnonymousMapper.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ public class AnonymousMapper<Input, Output> : Mapper<Input, Output>
+ {
+ readonly Converter<Input, Output> converter;
+
+ public AnonymousMapper(Converter<Input, Output> converter)
+ {
+ this.converter = converter;
+ }
+
+ public Output map_from(Input item)
+ {
+ return converter(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Builder.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Builder<T>
+ {
+ T build();
+ }
+}
\ No newline at end of file
product/commons/utility/Callback.cs
@@ -0,0 +1,10 @@
+namespace gorilla.commons.utility
+{
+ public interface Callback : Command
+ {
+ }
+
+ public interface Callback<T> : ParameterizedCommand<T>
+ {
+ }
+}
\ No newline at end of file
product/commons/utility/CallbackCommand.cs
@@ -0,0 +1,6 @@
+namespace gorilla.commons.utility
+{
+ public interface CallbackCommand<T> : ParameterizedCommand<Callback<T>>
+ {
+ }
+}
\ No newline at end of file
product/commons/utility/ChainedCommand.cs
@@ -0,0 +1,20 @@
+namespace gorilla.commons.utility
+{
+ public class ChainedCommand : Command
+ {
+ readonly Command left;
+ readonly Command right;
+
+ public ChainedCommand(Command left, Command right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public void run()
+ {
+ left.run();
+ right.run();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/ChainedConfiguration.cs
@@ -0,0 +1,20 @@
+namespace gorilla.commons.utility
+{
+ public class ChainedConfiguration<T> : Configuration<T>
+ {
+ readonly Configuration<T> first;
+ readonly Configuration<T> second;
+
+ public ChainedConfiguration(Configuration<T> first, Configuration<T> second)
+ {
+ this.first = first;
+ this.second = second;
+ }
+
+ public void configure(T item)
+ {
+ first.configure(item);
+ second.configure(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/ChainedMapper.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class ChainedMapper<Left, Middle, Right> : Mapper<Left, Right>
+ {
+ readonly Mapper<Left, Middle> left;
+ readonly Mapper<Middle, Right> right;
+
+ public ChainedMapper(Mapper<Left, Middle> left, Mapper<Middle, Right> right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public Right map_from(Left item)
+ {
+ return right.map_from(left.map_from(item));
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Clock.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace Gorilla.Commons.Utility
+{
+ public static class Clock
+ {
+ private static Func<DateTime> time_provider;
+
+ static Clock()
+ {
+ reset();
+ }
+
+ public static Date today()
+ {
+ return time_provider();
+ }
+
+ public static DateTime now()
+ {
+ return time_provider();
+ }
+
+#if DEBUG
+ public static void change_time_provider_to(Func<DateTime> new_time_provider)
+ {
+ if (new_time_provider != null) time_provider = new_time_provider;
+ }
+#endif
+
+ public static void reset()
+ {
+ time_provider = () => DateTime.Now;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Command.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Command
+ {
+ void run();
+ }
+}
\ No newline at end of file
product/commons/utility/CommandExtensions.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ static public class CommandExtensions
+ {
+ static public utility.Command then<Command>(this utility.Command left) where Command : utility.Command, new()
+ {
+ return then(left, new Command());
+ }
+
+ static public Command then(this Command left, Command right)
+ {
+ return new ChainedCommand(left, right);
+ }
+
+ static public Command then(this Command left, Action right)
+ {
+ return new ChainedCommand(left, new AnonymousCommand(right));
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/ComponentFactory.cs
@@ -0,0 +1,4 @@
+namespace gorilla.commons.utility
+{
+ public interface ComponentFactory<T> : Factory<T> where T : new() {}
+}
\ No newline at end of file
product/commons/utility/Configuration.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Configuration<T>
+ {
+ void configure(T item);
+ }
+}
\ No newline at end of file
product/commons/utility/ConfigurationExtensions.cs
@@ -0,0 +1,16 @@
+namespace gorilla.commons.utility
+{
+ static public class ConfigurationExtensions
+ {
+ static public Configuration<T> then<T>(this Configuration<T> first, Configuration<T> second)
+ {
+ return new ChainedConfiguration<T>(first, second);
+ }
+
+ static public T and_configure_with<T>(this T item, Configuration<T> configuration)
+ {
+ configuration.configure(item);
+ return item;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/ConfigurationExtensionsSpecs.cs
@@ -0,0 +1,29 @@
+using System.Data;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class ConfigurationExtensionsSpecs
+ {
+ public class when_configuring_an_item : concerns
+ {
+ it should_return_the_item_that_was_configured_when_completed = () => result.should_be_equal_to(item);
+
+ context c = () =>
+ {
+ configuration = an<Configuration<IDbCommand>>();
+ item = an<IDbCommand>();
+ };
+
+ because b = () =>
+ {
+ result = item.and_configure_with(configuration);
+ };
+
+ static Configuration<IDbCommand> configuration;
+ static IDbCommand item;
+ static IDbCommand result;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/ConversionExtensions.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections;
+
+namespace gorilla.commons.utility
+{
+ public static class ConversionExtensions
+ {
+ public static T downcast_to<T>(this object object_to_cast)
+ {
+ return (T) object_to_cast;
+ }
+
+ public static T converted_to<T>(this object item_to_convert)
+ {
+ if (item_to_convert.is_an_implementation_of<IConvertible>())
+ {
+ return (T) Convert.ChangeType(item_to_convert, typeof (T));
+ }
+ return item_to_convert.downcast_to<T>();
+ }
+
+ public static bool is_an_implementation_of<T>(this object item)
+ {
+ return item is T;
+ }
+
+ public static void call_on<T>(this object target, Action<T> action) where T : class
+ {
+ if (target as T != null) action(target as T);
+ }
+
+ public static void call_on_each<T>(this IEnumerable items, Action<T> action) where T : class
+ {
+ foreach (var item in items) item.call_on(action);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Date.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Globalization;
+using gorilla.commons.utility;
+
+namespace Gorilla.Commons.Utility
+{
+ [Serializable]
+ public class Date : IComparable<Date>, IComparable, IEquatable<Date>
+ {
+ readonly long ticks;
+
+ public Date(int year, int month, int day)
+ {
+ ticks = new DateTime(year, month, day).Ticks;
+ }
+
+ public bool is_in(Year the_year)
+ {
+ return the_year.represents(to_date_time());
+ }
+
+ public DateTime to_date_time()
+ {
+ return new DateTime(ticks);
+ }
+
+ static public implicit operator Date(DateTime date)
+ {
+ return new Date(date.Year, date.Month, date.Day);
+ }
+
+ static public implicit operator DateTime(Date date)
+ {
+ return date.to_date_time();
+ }
+
+ public int CompareTo(Date other)
+ {
+ var the_other_date = other.downcast_to<Date>();
+ if (ticks.Equals(the_other_date.ticks))
+ {
+ return 0;
+ }
+ return ticks > the_other_date.ticks ? 1 : -1;
+ }
+
+ public bool Equals(Date other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.ticks == ticks;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Date)) return false;
+ return Equals((Date) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return ticks.GetHashCode();
+ }
+
+ public static bool operator ==(Date left, Date right)
+ {
+ return Equals(left, right);
+ }
+
+ public static bool operator !=(Date left, Date right)
+ {
+ return !Equals(left, right);
+ }
+
+ public override string ToString()
+ {
+ return new DateTime(ticks, DateTimeKind.Local).ToString("MMM dd yyyy", CultureInfo.InvariantCulture);
+ }
+
+ int IComparable.CompareTo(object obj)
+ {
+ if (obj.is_an_implementation_of<Date>())
+ return CompareTo(obj.downcast_to<Date>());
+ throw new InvalidOperationException();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/DateSpecs.cs
@@ -0,0 +1,39 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Utility
+{
+ public class DateSpecs
+ {
+ }
+
+ [Concern(typeof (Date))]
+ public class when_two_dates_that_represent_the_same_day_are_asked_if_they_are_equal : concerns_for<Date>
+ {
+ it should_return_true = () => result.should_be_equal_to(true);
+
+ public override Date create_sut()
+ {
+ return new Date(2008, 09, 25);
+ }
+
+ because b = () => { result = sut.Equals(new Date(2008, 09, 25)); };
+
+ static bool result;
+ }
+
+ [Concern(typeof (Date))]
+ public class when_an_older_date_is_compared_to_a_younger_date : concerns_for<Date>
+ {
+ it should_return_a_positive_number = () => result.should_be_greater_than(0);
+
+ public override Date create_sut()
+ {
+ return new Date(2008, 09, 25);
+ }
+
+ because b = () => { result = sut.CompareTo(new Date(2007, 01, 01)); };
+
+ static int result;
+ }
+}
\ No newline at end of file
product/commons/utility/DefaultConstructorFactory.cs
@@ -0,0 +1,10 @@
+namespace gorilla.commons.utility
+{
+ public class DefaultConstructorFactory<T> : ComponentFactory<T> where T : new()
+ {
+ public T create()
+ {
+ return new T();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/DisposableCommand.cs
@@ -0,0 +1,7 @@
+using System;
+using gorilla.commons.utility;
+
+namespace gorilla.commons.Utility
+{
+ public interface DisposableCommand : Command, IDisposable {}
+}
\ No newline at end of file
product/commons/utility/EmptyCallback.cs
@@ -0,0 +1,9 @@
+namespace gorilla.commons.utility
+{
+ public class EmptyCallback<T> : Callback<T>, Callback
+ {
+ public void run(T item) {}
+
+ public void run() {}
+ }
+}
\ No newline at end of file
product/commons/utility/EmptyCommand.cs
@@ -0,0 +1,9 @@
+namespace gorilla.commons.utility
+{
+ public class EmptyCommand : Command
+ {
+ public void run()
+ {
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/EnumerableExtensions.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.commons.utility
+{
+ static public class EnumerableExtensions
+ {
+ static public IEnumerable<T> where<T>(this IEnumerable<T> items, Func<T, bool> condition_is_met)
+ {
+ return null == items ? Enumerable.Empty<T>() : items.Where(condition_is_met);
+ }
+
+ static public IList<T> databind<T>(this IEnumerable<T> items_to_bind_to)
+ {
+ return null == items_to_bind_to ? new List<T>() : items_to_bind_to.ToList();
+ }
+
+ static public IEnumerable<T> sorted_using<T>(this IEnumerable<T> items_to_sort, IComparer<T> sorting_algorithm)
+ {
+ var sorted_items = new List<T>(items_to_sort);
+ sorted_items.Sort(sorting_algorithm);
+ return sorted_items;
+ }
+
+ static public IEnumerable<T> all<T>(this IEnumerable<T> items)
+ {
+ foreach (var item in items ?? Enumerable.Empty<T>()) yield return item;
+ }
+
+ static public void each<T>(this IEnumerable<T> items, Action<T> action)
+ {
+ foreach (var item in items ?? Enumerable.Empty<T>()) action(item);
+ }
+
+ static public IEnumerable<T> join_with<T>(this IEnumerable<T> left, IEnumerable<T> right)
+ {
+ if (null == right) return left;
+
+ var list = new List<T>();
+ list.AddRange(left);
+ list.AddRange(right);
+ return list;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/EnumerableExtensionsSpecs.cs
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class EnumerableExtensionsSpecs
+ {
+ [Concern(typeof (EnumerableExtensions))]
+ public class when_joining_one_collection_with_another : concerns
+ {
+ it should_return_the_items_from_both = () =>
+ {
+ results.should_contain(1);
+ results.should_contain(2);
+ };
+
+ because b = () =>
+ {
+ results = new List<int> {1}.join_with(new List<int> {2});
+ };
+
+ static IEnumerable<int> results;
+ }
+
+ [Concern(typeof (EnumerableExtensions))]
+ public class when_attemping_to_join_a_list_with_a_null_value : concerns
+ {
+ it should_return_the_original_list = () => new List<int> {1}.join_with(null).should_contain(1);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Factory.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Factory<T>
+ {
+ T create();
+ }
+}
\ No newline at end of file
product/commons/utility/FactoryDelegate.cs
@@ -0,0 +1,6 @@
+namespace gorilla.commons.utility
+{
+ public delegate Out FactoryDelegate<In, Out>(In input);
+
+ public delegate Out FactoryDelegate<Out>();
+}
\ No newline at end of file
product/commons/utility/FilteredVisitor.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class FilteredVisitor<T> : Visitor<T>
+ {
+ readonly Specification<T> condition;
+ readonly Visitor<T> visitor;
+
+ public FilteredVisitor(Specification<T> condition, Visitor<T> visitor)
+ {
+ this.condition = condition;
+ this.visitor = visitor;
+ }
+
+ public void visit(T item_to_visit)
+ {
+ if (condition.is_satisfied_by(item_to_visit)) visitor.visit(item_to_visit);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/FuncExtensions.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ static public class FuncExtensions
+ {
+ static public readonly object mutex = new object();
+
+ static public Func<T> memorize<T>(this Func<T> item) where T : class
+ {
+ T the_implementation = null;
+ return () =>
+ {
+ if (null == the_implementation)
+ {
+ lock (mutex)
+ {
+ if (null == the_implementation)
+ {
+ the_implementation = item();
+ }
+ }
+ }
+ return the_implementation;
+ };
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/FuncSpecification.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ public class FuncSpecification<T> : Specification<T>
+ {
+ Func<T, bool> condition;
+
+ public FuncSpecification(Func<T, bool> condition)
+ {
+ this.condition = condition;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return condition(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Id.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ [Serializable]
+ public class Id<T>
+ {
+ static public readonly Id<T> Default = new Id<T>(default(T));
+ readonly T id;
+
+ public Id(T id)
+ {
+ this.id = id;
+ }
+
+ static public implicit operator Id<T>(T id)
+ {
+ return new Id<T>(id);
+ }
+
+ static public implicit operator T(Id<T> id)
+ {
+ return id.id;
+ }
+
+ public bool Equals(Id<T> other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(other.id, id);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Id<T>)) return false;
+ return Equals((Id<T>) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return id.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Identifiable.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Identifiable<T>
+ {
+ Id<T> id { get; }
+ }
+}
\ No newline at end of file
product/commons/utility/Import.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Import<T>
+ {
+ void import(T item);
+ }
+}
\ No newline at end of file
product/commons/utility/ListExtensions.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.commons.utility
+{
+ static public class ListExtensions
+ {
+ static public IListConstraint<T> add<T>(this ICollection<T> items, T item)
+ {
+ return new ListConstraint<T>(items, item);
+ }
+
+ static public IListConstraint<T> add_range<T>(this ICollection<T> items, IEnumerable<T> item)
+ {
+ return new ListConstraint<T>(items, item.ToArray());
+ }
+ }
+
+ public class ListConstraint<T> : IListConstraint<T>
+ {
+ readonly ICollection<T> items;
+ readonly T[] items_to_add;
+
+ public ListConstraint(ICollection<T> list_to_constrain, params T[] items_to_add)
+ {
+ items = list_to_constrain;
+ this.items_to_add = items_to_add;
+ items_to_add.each(list_to_constrain.Add);
+ }
+
+ public void unless(Func<T, bool> predicate)
+ {
+ items_to_add.where(predicate).each(x => items.Remove(x));
+ }
+ }
+
+ public interface IListConstraint<T>
+ {
+ void unless(Func<T, bool> predicate);
+ }
+}
\ No newline at end of file
product/commons/utility/ListExtensionsSpecs.cs
@@ -0,0 +1,67 @@
+using System.Collections.Generic;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class ListExtensionsSpecs
+ {
+ [Concern(typeof (ListExtensions))]
+ public class when_adding_an_item_to_a_list : concerns
+ {
+ because b = () =>
+ {
+ list = new List<string>();
+ list.add("mo");
+ };
+
+ it should_add_the_item_to_the_list = () => list.should_contain("mo");
+
+ static List<string> list;
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public abstract class when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met : concerns
+ {
+ context c = () =>
+ {
+ list = new List<string>();
+ };
+
+ static protected List<string> list;
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public class when_the_condition_is_not_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list.add("mo").unless(x => false);
+
+ it should_add_the_item_to_the_list = () => list.should_contain("mo");
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public class when_the_condition_is_met : when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list.add("mo").unless(x => true);
+
+ it should_not_add_the_item_to_the_list = () => list.should_not_contain("mo");
+ }
+
+ [Concern(typeof (ListExtensions))]
+ public class when_some_of_the_items_meet_the_conditions_and_some_do_not :
+ when_asked_to_only_add_an_item_to_a_list_if_a_condition_is_not_met
+ {
+ because b = () => list
+ .add_range(new List<string> {"mo", "khan"})
+ .unless(x => x.Equals("mo"));
+
+ it should_add_the_items_that_do_not_meet_the_condition = () =>
+ {
+ list.Count.should_be_equal_to(1);
+ list.should_contain("khan");
+ };
+
+ it should_not_add_the_items_that_do_meet_the_condition = () => list.should_not_contain("mo");
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Mapper.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Mapper<Input, Output>
+ {
+ Output map_from(Input item);
+ }
+}
\ No newline at end of file
product/commons/utility/MappingExtensions.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.commons.utility
+{
+ public static class MappingExtensions
+ {
+ public static Output map_using<Input, Output>(this Input item, Converter<Input, Output> conversion)
+ {
+ return conversion(item);
+ }
+
+ public static Output map_using<Input, Output>(this Input item, Mapper<Input, Output> mapper)
+ {
+ return map_using(item, x => mapper.map_from(x));
+ }
+
+ public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
+ Converter<Input, Output> mapper)
+ {
+ return null == items ? new List<Output>() : items.Select(x => mapper(x));
+ }
+
+ public static IEnumerable<Output> map_all_using<Input, Output>(this IEnumerable<Input> items,
+ Mapper<Input, Output> mapper)
+ {
+ return map_all_using(items, x => mapper.map_from(x));
+ }
+
+ public static Mapper<Left, Right> then<Left, Middle, Right>(this Mapper<Left, Middle> left,
+ Mapper<Middle, Right> right)
+ {
+ return new ChainedMapper<Left, Middle, Right>(left, right);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/MappingExtensionsSpecs.cs
@@ -0,0 +1,29 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ [Concern(typeof (MappingExtensions))]
+ public class when_transforming_type_A_to_type_B_then_C : concerns
+ {
+ it should_return_the_correct_result = () => result.should_be_equal_to(1);
+
+ context c = () =>
+ {
+ first_mapper = an<Mapper<object, string>>();
+ second_mapper = an<Mapper<string, int>>();
+ a = 1;
+
+ when_the(first_mapper).is_told_to(x => x.map_from(a)).it_will_return("1");
+ when_the(second_mapper).is_told_to(x => x.map_from("1")).it_will_return(1);
+ };
+
+ because b = () => { result = first_mapper.then(second_mapper).map_from(a); };
+
+
+ static int result;
+ static Mapper<object, string> first_mapper;
+ static Mapper<string, int> second_mapper;
+ static object a;
+ }
+}
\ No newline at end of file
product/commons/utility/Notification.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Notification
+ {
+ void notify(params NotificationMessage[] messages);
+ }
+}
\ No newline at end of file
product/commons/utility/NotificationMessage.cs
@@ -0,0 +1,42 @@
+namespace gorilla.commons.utility
+{
+ public class NotificationMessage
+ {
+ public virtual string message { get; set; }
+
+ static public implicit operator string(NotificationMessage message)
+ {
+ return message.ToString();
+ }
+
+ static public implicit operator NotificationMessage(string message)
+ {
+ return new NotificationMessage {message = message};
+ }
+
+ public override string ToString()
+ {
+ return message;
+ }
+
+ public bool Equals(NotificationMessage obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ return Equals(obj.message, message);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (NotificationMessage)) return false;
+ return Equals((NotificationMessage) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (message != null ? message.GetHashCode() : 0);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/NotSpecification.cs
@@ -0,0 +1,17 @@
+namespace gorilla.commons.utility
+{
+ public class NotSpecification<T> : Specification<T>
+ {
+ readonly Specification<T> item_to_match;
+
+ public NotSpecification(Specification<T> item_to_match)
+ {
+ this.item_to_match = item_to_match;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return !item_to_match.is_satisfied_by(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/NotSpecificationSpecs.cs
@@ -0,0 +1,54 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class NotSpecificationSpecs
+ {
+ [Concern(typeof (NotSpecification<>))]
+ public class when_checking_if_a_condition_is_not_met : concerns_for<Specification<int>, NotSpecification<int>>
+ {
+ static protected Specification<int> criteria;
+
+ context c = () =>
+ {
+ criteria = the_dependency<Specification<int>>();
+ };
+
+ public override Specification<int> create_sut()
+ {
+ return new NotSpecification<int>(criteria);
+ }
+ }
+
+ [Concern(typeof (NotSpecification<>))]
+ public class when_a_condition_is_not_met : when_checking_if_a_condition_is_not_met
+ {
+ context c = () => when_the(criteria).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ it should_return_true = () => result.should_be_true();
+
+ static bool result;
+ }
+
+ [Concern(typeof (NotSpecification<>))]
+ public class when_a_condition_is_met : when_checking_if_a_condition_is_not_met
+ {
+ context c = () => when_the(criteria).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ it should_return_false = () => result.should_be_false();
+
+ static bool result;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/NumericConversions.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ public static class NumericConversions
+ {
+ public static int to_int<T>(this T item) where T : IConvertible
+ {
+ return Convert.ChangeType(item, typeof (int)).downcast_to<int>();
+ }
+
+ public static long to_long<T>(this T item) where T : IConvertible
+ {
+ return Convert.ChangeType(item, typeof (long)).downcast_to<long>();
+ }
+
+ public static double to_double<T>(this T item) where T : IConvertible
+ {
+ return Convert.ChangeType(item, typeof (double)).downcast_to<double>();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/NumericConversionsSpecs.cs
@@ -0,0 +1,31 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ [Concern(typeof (NumericConversions))]
+ public class when_converting_a_valid_string_to_a_long : concerns
+ {
+ it should_return_the_correct_result = () => result.should_be_equal_to(88L);
+
+ context c = () => { valid_numeric_string = "88"; };
+
+ because b = () => { result = valid_numeric_string.to_long(); };
+
+ static long result;
+ static string valid_numeric_string;
+ }
+
+ [Concern(typeof (NumericConversions))]
+ public class when_converting_a_valid_string_to_an_int : concerns
+ {
+ it should_return_the_correct_result = () => result.should_be_equal_to(66);
+
+ context c = () => { valid_numeric_string = "66"; };
+
+ because b = () => { result = valid_numeric_string.to_int(); };
+
+ static int result;
+ static string valid_numeric_string;
+ }
+}
\ No newline at end of file
product/commons/utility/OrSpecification.cs
@@ -0,0 +1,19 @@
+namespace gorilla.commons.utility
+{
+ public class OrSpecification<T> : Specification<T>
+ {
+ readonly Specification<T> left;
+ readonly Specification<T> right;
+
+ public OrSpecification(Specification<T> left, Specification<T> right)
+ {
+ this.left = left;
+ this.right = right;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return left.is_satisfied_by(item) || right.is_satisfied_by(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/OrSpecificationSpecs.cs
@@ -0,0 +1,69 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class OrSpecificationSpecs
+ {
+ [Concern(typeof (OrSpecification<>))]
+ public abstract class when_checking_if_one_of_two_conditions_are_met : concerns_for<Specification<int>, OrSpecification<int>>
+ {
+ public override Specification<int> create_sut()
+ {
+ return new OrSpecification<int>(left, right);
+ }
+
+ context c = () =>
+ {
+ left = an<Specification<int>>();
+ right = an<Specification<int>>();
+ };
+
+ static protected Specification<int> left;
+ static protected Specification<int> right;
+ }
+
+ [Concern(typeof (OrSpecification<>))]
+ public class when_one_of_the_conditions_is_met : when_checking_if_one_of_two_conditions_are_met
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () => when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (OrSpecification<>))]
+ public class when_the_second_condition_is_met : when_checking_if_one_of_two_conditions_are_met
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () => when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (OrSpecification<>))]
+ public class when_neither_conditions_are_met : when_checking_if_one_of_two_conditions_are_met
+ {
+ it should_return_false = () => result.should_be_false();
+
+ because b = () =>
+ {
+ result = sut.is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/ParameterizedCommand.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface ParameterizedCommand<T>
+ {
+ void run(T item);
+ }
+}
\ No newline at end of file
product/commons/utility/Parser.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Parser<T>
+ {
+ T parse();
+ }
+}
\ No newline at end of file
product/commons/utility/Percent.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Globalization;
+
+namespace Gorilla.Commons.Utility
+{
+ public class Percent
+ {
+ readonly double percentage;
+
+ public Percent(double percentage)
+ {
+ this.percentage = percentage;
+ }
+
+ public Percent(double portion_of_total, double total)
+ {
+ percentage = portion_of_total/total;
+ percentage *= 100;
+ percentage = Math.Round(percentage, 1);
+ }
+
+ public bool represents(Percent other_percent)
+ {
+ return Equals(other_percent);
+ }
+
+ public bool is_less_than(Percent other_percent)
+ {
+ return percentage.CompareTo(other_percent.percentage) < 0;
+ }
+
+ public static implicit operator Percent(double percentage)
+ {
+ return new Percent(percentage);
+ }
+
+ public bool Equals(Percent other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.percentage == percentage;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Percent)) return false;
+ return Equals((Percent) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return percentage.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return percentage.ToString(CultureInfo.InvariantCulture);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/PercentSpecs.cs
@@ -0,0 +1,35 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace Gorilla.Commons.Utility
+{
+ [Concern(typeof (Percent))]
+ public class when_comparing_fifty_divided_by_one_hundred_to_fifty_percent : concerns
+ {
+ it they_should_be_equal = () => new Percent(50, 100).should_be_equal_to<Percent>(50);
+ }
+
+ [Concern(typeof (Percent))]
+ public class when_calculating_a_fractional_percentage : concerns
+ {
+ it should_return_the_correct_percentage = () => new Percent(30, 90).should_be_equal_to<Percent>(33.3);
+ }
+
+ [Concern(typeof (Percent))]
+ public class when_checking_if_50_percent_is_less_than_51_percent : concerns
+ {
+ it should_return_true = () => new Percent(50).is_less_than(new Percent(51)).should_be_true();
+ }
+
+ [Concern(typeof (Percent))]
+ public class when_checking_if_51_percent_is_less_than_50_percent : concerns
+ {
+ it should_return_false = () => new Percent(51).is_less_than(new Percent(50)).should_be_false();
+ }
+
+ [Concern(typeof (Percent))]
+ public class when_checking_if_50_percent_is_less_than_50_percent : concerns
+ {
+ it should_return_false = () => new Percent(50).is_less_than(new Percent(50)).should_be_false();
+ }
+}
\ No newline at end of file
product/commons/utility/PredicateSpecification.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace gorilla.commons.utility
+{
+ public class PredicateSpecification<T> : Specification<T>
+ {
+ readonly Predicate<T> criteria;
+
+ public PredicateSpecification(Predicate<T> criteria)
+ {
+ this.criteria = criteria;
+ }
+
+ public bool is_satisfied_by(T item)
+ {
+ return criteria(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/PredicateSpecificationSpecs.cs
@@ -0,0 +1,20 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class PredicateSpecificationSpecs
+ {
+ [Concern(typeof (PredicateSpecification<>))]
+ public class when_checking_if_a_criteria_is_met_and_it_is : concerns
+ {
+ it should_return_true = () => new PredicateSpecification<int>(x => true).is_satisfied_by(1).should_be_true();
+ }
+
+ [Concern(typeof (PredicateSpecification<>))]
+ public class when_checking_if_a_criteria_is_met_and_it_is_not : concerns
+ {
+ it should_return_true = () => new PredicateSpecification<int>(x => false).is_satisfied_by(1).should_be_false();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Query.cs
@@ -0,0 +1,12 @@
+namespace gorilla.commons.utility
+{
+ public interface Query<TOutput>
+ {
+ TOutput fetch();
+ }
+
+ public interface Query<TInput, TOutput>
+ {
+ TOutput fetch(TInput item);
+ }
+}
\ No newline at end of file
product/commons/utility/Registry.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace gorilla.commons.utility
+{
+ public interface Registry<T> : IEnumerable<T>
+ {
+ IEnumerable<T> all();
+ }
+}
\ No newline at end of file
product/commons/utility/RegistryExtensions.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace gorilla.commons.utility
+{
+ public static class RegistryExtensions
+ {
+ public static K find_an_implementation_of<T, K>(this Registry<T> registry) where K : T
+ {
+ try
+ {
+ return registry
+ .all()
+ .Single(p => p.is_an_implementation_of<K>())
+ .downcast_to<K>();
+ }
+ catch (Exception exception)
+ {
+ throw new Exception("Could Not Find an implementation of".formatted_using(typeof (K)), exception);
+ }
+ }
+
+ public static IEnumerable<T> sort_all_using<T>(this Registry<T> registry, IComparer<T> comparer)
+ {
+ return registry.all().sorted_using(comparer);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Specification.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Specification<T>
+ {
+ bool is_satisfied_by(T item);
+ }
+}
\ No newline at end of file
product/commons/utility/SpecificationExtensions.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+
+namespace gorilla.commons.utility
+{
+ static public class SpecificationExtensions
+ {
+ static public IEnumerable<T> that_satisfy<T>(this IEnumerable<T> items_to_peek_in_to,
+ Predicate<T> criteria_to_satisfy)
+ {
+ foreach (var item in items_to_peek_in_to ?? new List<T>())
+ if (item.satisfies(criteria_to_satisfy)) yield return item;
+ }
+
+ static public bool satisfies<T>(this T item_to_interrogate, Predicate<T> criteria_to_satisfy)
+ {
+ return criteria_to_satisfy(item_to_interrogate);
+ }
+
+ static public bool satisfies<T>(this T item_to_validate, Specification<T> criteria_to_satisfy)
+ {
+ return item_to_validate.satisfies(criteria_to_satisfy.is_satisfied_by);
+ }
+
+ static public Specification<T> and<T>(this Specification<T> left, Specification<T> right)
+ {
+ return new PredicateSpecification<T>(x => left.is_satisfied_by(x) && right.is_satisfied_by(x));
+ }
+
+ static public Specification<T> or<T>(this Specification<T> left, Specification<T> right)
+ {
+ return new PredicateSpecification<T>(x => left.is_satisfied_by(x) || right.is_satisfied_by(x));
+ }
+
+ static public Specification<T> not<T>(this Specification<T> original)
+ {
+ return new PredicateSpecification<T>(x => !original.is_satisfied_by(x));
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/SpecificationExtensionsSpecs.cs
@@ -0,0 +1,78 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class SpecificationExtensionsSpecs
+ {
+ public abstract class when_evaluating_two_conditions : concerns
+ {
+ context c = () =>
+ {
+ left = an<Specification<int>>();
+ right = an<Specification<int>>();
+ };
+
+ static protected Specification<int> left;
+ static protected Specification<int> right;
+ }
+
+ [Concern(typeof (SpecificationExtensions))]
+ public class when_checking_if_two_conditions_are_met_and_they_are : when_evaluating_two_conditions
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () =>
+ {
+ when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ };
+
+ because b = () =>
+ {
+ result = left.or(right).is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (SpecificationExtensions))]
+ public class when_checking_if_one_of_two_conditions_are_met_and_the_left_one_is_not : when_evaluating_two_conditions
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () =>
+ {
+ when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
+ };
+
+ because b = () =>
+ {
+ result = left.or(right).is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+
+ [Concern(typeof (SpecificationExtensions))]
+ public class when_checking_if_one_of_two_conditions_are_met_and_the_right_one_is_not :
+ when_evaluating_two_conditions
+ {
+ it should_return_true = () => result.should_be_true();
+
+ context c = () =>
+ {
+ when_the(right).is_told_to(x => x.is_satisfied_by(1)).it_will_return(false);
+ when_the(left).is_told_to(x => x.is_satisfied_by(1)).it_will_return(true);
+ };
+
+ because b = () =>
+ {
+ result = left.or(right).is_satisfied_by(1);
+ };
+
+ static bool result;
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/State.cs
@@ -0,0 +1,6 @@
+namespace gorilla.commons.utility
+{
+ public interface State
+ {
+ }
+}
\ No newline at end of file
product/commons/utility/StringExtensions.cs
@@ -0,0 +1,25 @@
+namespace gorilla.commons.utility
+{
+ static public class StringExtensions
+ {
+ static public string formatted_using(this string formatted_string, params object[] arguments)
+ {
+ return string.Format(formatted_string, arguments);
+ }
+
+ static public bool is_equal_to_ignoring_case(this string left, string right)
+ {
+ return string.Compare(left, right, true) == 0;
+ }
+
+ static public bool is_blank(this string message)
+ {
+ return string.IsNullOrEmpty(message);
+ }
+
+ static public string to_string<T>(this T item)
+ {
+ return "{0}".formatted_using(item);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/SubjectOf.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface SubjectOf<State> where State : utility.State
+ {
+ void change_state_to(State new_state);
+ }
+}
\ No newline at end of file
product/commons/utility/TypeExtensions.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Linq;
+using System.Reflection;
+
+namespace gorilla.commons.utility
+{
+ public static class TypeExtensions
+ {
+ public static Type last_interface(this Type type)
+ {
+ return type.GetInterfaces()[type.GetInterfaces().Length - 1];
+ }
+
+ public static Type first_interface(this Type type)
+ {
+ return type.GetInterfaces()[0];
+ }
+
+ public static bool is_a_generic_type(this Type type)
+ {
+ //return type.IsGenericType;
+ return type.IsGenericTypeDefinition;
+ }
+
+ public static object default_value(this Type type)
+ {
+ return (type.IsValueType ? Activator.CreateInstance(type) : null);
+ }
+
+ public static Attribute get_attribute<Attribute>(this ICustomAttributeProvider provider)
+ where Attribute : System.Attribute
+ {
+ return
+ provider
+ .GetCustomAttributes(typeof (Attribute), false)
+ .Select(x => x.downcast_to<Attribute>())
+ .First();
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/TypeExtensionsSpecs.cs
@@ -0,0 +1,39 @@
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+
+namespace gorilla.commons.utility
+{
+ public class TypeExtensionsSpecs
+ {
+ [Concern(typeof (TypeExtensions))]
+ public class when_getting_the_last_interface_for_a_type : concerns
+ {
+ it should_return_the_correct_one =
+ () => typeof (TestType).last_interface().should_be_equal_to(typeof (ITestType));
+ }
+
+ [Concern(typeof (TypeExtensions))]
+ public class when_getting_the_first_interface_for_a_type : concerns
+ {
+ it should_return_the_correct_one = () => typeof (TestType).first_interface().should_be_equal_to(typeof (IBase));
+ }
+
+ [Concern(typeof (TypeExtensions))]
+ public class when_checking_if_a_type_represents_a_generic_type_definition : concerns
+ {
+ it should_tell_the_truth = () =>
+ {
+ typeof (Registry<>).is_a_generic_type().should_be_true();
+ typeof (Registry<int>).is_a_generic_type().should_be_false();
+ };
+ }
+
+ public interface IBase {}
+
+ public class BaseType : IBase {}
+
+ public interface ITestType {}
+
+ public class TestType : BaseType, ITestType {}
+ }
+}
\ No newline at end of file
product/commons/utility/utility.csproj
@@ -0,0 +1,147 @@
+๏ปฟ<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>gorilla.commons.utility</RootNamespace>
+ <AssemblyName>gorilla.commons.utility</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
+ </Reference>
+ <Reference Include="developwithpassion.bdd, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\developwithpassion\developwithpassion.bdd.dll</HintPath>
+ </Reference>
+ <Reference Include="Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\test\rhino.mocks\Rhino.Mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Clock.cs" />
+ <Compile Include="AnonymousCommand.cs" />
+ <Compile Include="AndSpecification.cs" />
+ <Compile Include="AnonymousDisposable.cs" />
+ <Compile Include="ChainedCommand.cs" />
+ <Compile Include="ChainedConfiguration.cs" />
+ <Compile Include="ChainedMapper.cs" />
+ <Compile Include="EmptyCallback.cs" />
+ <Compile Include="EmptyCommand.cs" />
+ <Compile Include="DefaultConstructorFactory.cs" />
+ <Compile Include="FactoryDelegate.cs" />
+ <Compile Include="FilteredVisitor.cs" />
+ <Compile Include="FuncSpecification.cs" />
+ <Compile Include="Builder.cs" />
+ <Compile Include="Callback.cs" />
+ <Compile Include="CallbackCommand.cs" />
+ <Compile Include="Command.cs" />
+ <Compile Include="Configuration.cs" />
+ <Compile Include="ComponentFactory.cs" />
+ <Compile Include="Id.cs" />
+ <Compile Include="DisposableCommand.cs" />
+ <Compile Include="Factory.cs" />
+ <Compile Include="Identifiable.cs" />
+ <Compile Include="Import.cs" />
+ <Compile Include="Mapper.cs" />
+ <Compile Include="Notification.cs" />
+ <Compile Include="ParameterizedCommand.cs" />
+ <Compile Include="Parser.cs" />
+ <Compile Include="Query.cs" />
+ <Compile Include="Registry.cs" />
+ <Compile Include="Specification.cs" />
+ <Compile Include="State.cs" />
+ <Compile Include="SubjectOf.cs" />
+ <Compile Include="ValueReturningVisitor.cs" />
+ <Compile Include="Visitable.cs" />
+ <Compile Include="Visitor.cs" />
+ <Compile Include="AnonymousMapper.cs" />
+ <Compile Include="NotificationMessage.cs" />
+ <Compile Include="NotSpecification.cs" />
+ <Compile Include="NotSpecificationSpecs.cs" />
+ <Compile Include="OrSpecification.cs" />
+ <Compile Include="OrSpecificationSpecs.cs" />
+ <Compile Include="PredicateSpecification.cs" />
+ <Compile Include="PredicateSpecificationSpecs.cs" />
+ <Compile Include="Date.cs" />
+ <Compile Include="DateSpecs.cs" />
+ <Compile Include="CommandExtensions.cs" />
+ <Compile Include="ConfigurationExtensions.cs" />
+ <Compile Include="ConfigurationExtensionsSpecs.cs" />
+ <Compile Include="ConversionExtensions.cs" />
+ <Compile Include="EnumerableExtensions.cs" />
+ <Compile Include="EnumerableExtensionsSpecs.cs" />
+ <Compile Include="FuncExtensions.cs" />
+ <Compile Include="ListExtensions.cs" />
+ <Compile Include="ListExtensionsSpecs.cs" />
+ <Compile Include="MappingExtensions.cs" />
+ <Compile Include="MappingExtensionsSpecs.cs" />
+ <Compile Include="NumericConversions.cs" />
+ <Compile Include="NumericConversionsSpecs.cs" />
+ <Compile Include="RegistryExtensions.cs" />
+ <Compile Include="SpecificationExtensionsSpecs.cs" />
+ <Compile Include="SpecificationExtensions.cs" />
+ <Compile Include="StringExtensions.cs" />
+ <Compile Include="TypeExtensions.cs" />
+ <Compile Include="TypeExtensionsSpecs.cs" />
+ <Compile Include="VisitorExtensions.cs" />
+ <Compile Include="Percent.cs" />
+ <Compile Include="PercentSpecs.cs" />
+ <Compile Include="Year.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\testing\test.helpers.csproj">
+ <Project>{44E65096-9657-4716-90F8-4535BABE8039}</Project>
+ <Name>test.helpers</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </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>
product/commons/utility/ValueReturningVisitor.cs
@@ -0,0 +1,8 @@
+namespace gorilla.commons.utility
+{
+ public interface ValueReturningVisitor<Value, T> : Visitor<T>
+ {
+ Value value { get; }
+ void reset();
+ }
+}
\ No newline at end of file
product/commons/utility/Visitable.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Visitable<T>
+ {
+ void accept(Visitor<T> visitor);
+ }
+}
\ No newline at end of file
product/commons/utility/Visitor.cs
@@ -0,0 +1,7 @@
+namespace gorilla.commons.utility
+{
+ public interface Visitor<T>
+ {
+ void visit(T item_to_visit);
+ }
+}
\ No newline at end of file
product/commons/utility/VisitorExtensions.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+
+namespace gorilla.commons.utility
+{
+ static public class VisitorExtensions
+ {
+ static public Result return_value_from_visiting_all_with<Result, T>(this IEnumerable<T> items, ValueReturningVisitor<Result, T> visitor)
+ {
+ visitor.reset();
+ items.vist_all_with(visitor);
+ return visitor.value;
+ }
+
+ static public void vist_all_with<T>(this IEnumerable<T> items, Visitor<T> visitor)
+ {
+ items.each(visitor.visit);
+ }
+ }
+}
\ No newline at end of file
product/commons/utility/Year.cs
@@ -0,0 +1,53 @@
+using System;
+
+namespace Gorilla.Commons.Utility
+{
+ public class Year
+ {
+ readonly int the_underlying_year;
+
+ public Year(int year) : this(new DateTime(year, 01, 01))
+ {
+ }
+
+ public Year(DateTime date)
+ {
+ the_underlying_year = date.Year;
+ }
+
+ static public implicit operator Year(int year)
+ {
+ return new Year(year);
+ }
+
+ public bool Equals(Year obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ return obj.the_underlying_year == the_underlying_year;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Year)) return false;
+ return Equals((Year) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return the_underlying_year;
+ }
+
+ public bool represents(DateTime time)
+ {
+ return time.Year.Equals(the_underlying_year);
+ }
+
+ public override string ToString()
+ {
+ return the_underlying_year.ToString();
+ }
+ }
+}
\ No newline at end of file
solution.sln
@@ -3,23 +3,39 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "build", "build\build.csproj", "{B8505B10-85C7-45F4-B039-D364DD556D7D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "boot", "product\boot\boot.csproj", "{2DB82691-BF15-4538-8C5E-6BF8F4F875A9}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client", "client", "{07187CAA-7272-4E29-A736-5CBD5118D40B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domain", "product\domain\domain.csproj", "{BE790BCC-4412-473F-9D0A-5AA48FE7A74F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "boot", "product\client\boot\boot.csproj", "{2DB82691-BF15-4538-8C5E-6BF8F4F875A9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service", "product\service\service.csproj", "{7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "database", "product\client\database\database.csproj", "{580E68A8-EDEE-4350-8BBE-A053645B0F83}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "database", "product\database\database.csproj", "{580E68A8-EDEE-4350-8BBE-A053645B0F83}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domain", "product\client\domain\domain.csproj", "{BE790BCC-4412-473F-9D0A-5AA48FE7A74F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dto", "product\dto\dto.csproj", "{ACF52FAB-435B-48C9-A383-C787CB2D8000}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domain.services", "product\client\domain.services\domain.services.csproj", "{F04F922F-C0CC-45FC-BD33-A758BD1B8B36}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presentation", "product\presentation\presentation.csproj", "{D7C83DB3-492D-4514-8C53-C57AD8E7ACE7}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dto", "product\client\dto\dto.csproj", "{ACF52FAB-435B-48C9-A383-C787CB2D8000}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service.contracts", "product\service.contracts\service.contracts.csproj", "{41D2B68B-031B-44FF-BAC5-7752D9E29F94}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presentation", "product\client\presentation\presentation.csproj", "{D7C83DB3-492D-4514-8C53-C57AD8E7ACE7}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service.infrastructure", "product\service.infrastructure\service.infrastructure.csproj", "{81412692-F3EE-4FBF-A7C7-69454DD1BD46}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service", "product\client\service\service.csproj", "{7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domain.services", "product\domain.services\domain.services.csproj", "{F04F922F-C0CC-45FC-BD33-A758BD1B8B36}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service.contracts", "product\client\service.contracts\service.contracts.csproj", "{41D2B68B-031B-44FF-BAC5-7752D9E29F94}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service.infrastructure", "product\client\service.infrastructure\service.infrastructure.csproj", "{81412692-F3EE-4FBF-A7C7-69454DD1BD46}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "utility", "product\client\utility\utility.csproj", "{22DF610D-CBC8-4042-A470-ABF246C5DDD4}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "commons", "commons", "{099D479D-7BFC-428E-A897-9189C294C9C8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure", "product\commons\infrastructure\infrastructure.csproj", "{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure.thirdparty", "product\commons\infrastructure.thirdparty\infrastructure.thirdparty.csproj", "{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure.thirdparty.log4net", "product\commons\infrastructure.thirdparty.log4net\infrastructure.thirdparty.log4net.csproj", "{6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test.helpers", "product\commons\testing\test.helpers.csproj", "{44E65096-9657-4716-90F8-4535BABE8039}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "utility", "product\commons\utility\utility.csproj", "{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -35,18 +51,18 @@ Global
{2DB82691-BF15-4538-8C5E-6BF8F4F875A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DB82691-BF15-4538-8C5E-6BF8F4F875A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DB82691-BF15-4538-8C5E-6BF8F4F875A9}.Release|Any CPU.Build.0 = Release|Any CPU
- {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Release|Any CPU.Build.0 = Release|Any CPU
- {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Release|Any CPU.Build.0 = Release|Any CPU
{580E68A8-EDEE-4350-8BBE-A053645B0F83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{580E68A8-EDEE-4350-8BBE-A053645B0F83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{580E68A8-EDEE-4350-8BBE-A053645B0F83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{580E68A8-EDEE-4350-8BBE-A053645B0F83}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BE790BCC-4412-473F-9D0A-5AA48FE7A74F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Release|Any CPU.Build.0 = Release|Any CPU
{ACF52FAB-435B-48C9-A383-C787CB2D8000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACF52FAB-435B-48C9-A383-C787CB2D8000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACF52FAB-435B-48C9-A383-C787CB2D8000}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -55,6 +71,10 @@ Global
{D7C83DB3-492D-4514-8C53-C57AD8E7ACE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7C83DB3-492D-4514-8C53-C57AD8E7ACE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7C83DB3-492D-4514-8C53-C57AD8E7ACE7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB}.Release|Any CPU.Build.0 = Release|Any CPU
{41D2B68B-031B-44FF-BAC5-7752D9E29F94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41D2B68B-031B-44FF-BAC5-7752D9E29F94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41D2B68B-031B-44FF-BAC5-7752D9E29F94}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -63,12 +83,49 @@ Global
{81412692-F3EE-4FBF-A7C7-69454DD1BD46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81412692-F3EE-4FBF-A7C7-69454DD1BD46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81412692-F3EE-4FBF-A7C7-69454DD1BD46}.Release|Any CPU.Build.0 = Release|Any CPU
- {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F04F922F-C0CC-45FC-BD33-A758BD1B8B36}.Release|Any CPU.Build.0 = Release|Any CPU
+ {22DF610D-CBC8-4042-A470-ABF246C5DDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {22DF610D-CBC8-4042-A470-ABF246C5DDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {22DF610D-CBC8-4042-A470-ABF246C5DDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {22DF610D-CBC8-4042-A470-ABF246C5DDD4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AA5EEED9-4531-45F7-AFCD-AD9717D2E405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AA5EEED9-4531-45F7-AFCD-AD9717D2E405}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AA5EEED9-4531-45F7-AFCD-AD9717D2E405}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AA5EEED9-4531-45F7-AFCD-AD9717D2E405}.Release|Any CPU.Build.0 = Release|Any CPU
+ {04DC09B4-5DF9-44A6-8DD1-05941F0D0228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {04DC09B4-5DF9-44A6-8DD1-05941F0D0228}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {04DC09B4-5DF9-44A6-8DD1-05941F0D0228}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {04DC09B4-5DF9-44A6-8DD1-05941F0D0228}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6BDCB0C1-51E1-435A-93D8-CA02BF8E409C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {44E65096-9657-4716-90F8-4535BABE8039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {44E65096-9657-4716-90F8-4535BABE8039}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {44E65096-9657-4716-90F8-4535BABE8039}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {44E65096-9657-4716-90F8-4535BABE8039}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {2DB82691-BF15-4538-8C5E-6BF8F4F875A9} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {580E68A8-EDEE-4350-8BBE-A053645B0F83} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {BE790BCC-4412-473F-9D0A-5AA48FE7A74F} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {F04F922F-C0CC-45FC-BD33-A758BD1B8B36} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {ACF52FAB-435B-48C9-A383-C787CB2D8000} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {D7C83DB3-492D-4514-8C53-C57AD8E7ACE7} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {7EA4C557-6EF2-4B1F-85C8-5B3F51BAD8DB} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {41D2B68B-031B-44FF-BAC5-7752D9E29F94} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {81412692-F3EE-4FBF-A7C7-69454DD1BD46} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {22DF610D-CBC8-4042-A470-ABF246C5DDD4} = {07187CAA-7272-4E29-A736-5CBD5118D40B}
+ {AA5EEED9-4531-45F7-AFCD-AD9717D2E405} = {099D479D-7BFC-428E-A897-9189C294C9C8}
+ {04DC09B4-5DF9-44A6-8DD1-05941F0D0228} = {099D479D-7BFC-428E-A897-9189C294C9C8}
+ {6BDCB0C1-51E1-435A-93D8-CA02BF8E409C} = {099D479D-7BFC-428E-A897-9189C294C9C8}
+ {44E65096-9657-4716-90F8-4535BABE8039} = {099D479D-7BFC-428E-A897-9189C294C9C8}
+ {DD8FD29E-7424-415C-9BA3-7D9F6ECBA161} = {099D479D-7BFC-428E-A897-9189C294C9C8}
+ EndGlobalSection
EndGlobal