Skip to content
Browse files

Set default Id to type of Guid. Also broke all the tests and a couple…

… of other things. Got rid of commands for now.
  • Loading branch information...
1 parent 448ecb9 commit 2ee9f36cbf9b56101936857b22ed184feea05c0c @geoffreysmith geoffreysmith committed Jun 13, 2011
Showing with 25 additions and 522 deletions.
  1. +0 −20 Solutions/SharpArch.Domain/Commands/CommandBase.cs
  2. +0 −12 Solutions/SharpArch.Domain/Commands/CommandHandlerNotFoundException.cs
  3. +0 −30 Solutions/SharpArch.Domain/Commands/CommandProcessor.cs
  4. +0 −12 Solutions/SharpArch.Domain/Commands/CommandResult.cs
  5. +0 −31 Solutions/SharpArch.Domain/Commands/CommandResults.cs
  6. +0 −11 Solutions/SharpArch.Domain/Commands/ICommand.cs
  7. +0 −7 Solutions/SharpArch.Domain/Commands/ICommandHandler.cs
  8. +0 −7 Solutions/SharpArch.Domain/Commands/ICommandProcessor.cs
  9. +0 −7 Solutions/SharpArch.Domain/Commands/ICommandResult.cs
  10. +0 −9 Solutions/SharpArch.Domain/Commands/ICommandResults.cs
  11. +1 −1 Solutions/SharpArch.Domain/DomainModel/Entity.cs
  12. +0 −51 Solutions/SharpArch.Domain/Events/DomainEvents.cs
  13. +0 −6 Solutions/SharpArch.Domain/Events/IDomainEvent.cs
  14. +0 −7 Solutions/SharpArch.Domain/Events/IHandles.cs
  15. +3 −1 Solutions/SharpArch.Domain/PersistenceSupport/IRepository.cs
  16. +0 −13 Solutions/SharpArch.Domain/SharpArch.Domain.csproj
  17. +3 −1 Solutions/SharpArch.NHibernate/Contracts/Repositories/INHibernateRepository.cs
  18. +3 −1 Solutions/SharpArch.NHibernate/NHibernateRepository.cs
  19. +0 −1 Solutions/SharpArch.Specifications/SharpArch.Domain/DomainModel/EntityWithTypedIdSpecs.cs
  20. +0 −4 Solutions/SharpArch.Specifications/SharpArch.Specifications.csproj
  21. +0 −122 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/CommandProcessorTests.cs
  22. +0 −39 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/CommandTests.cs
  23. +0 −15 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/InvalidCommand.cs
  24. +0 −9 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommand.cs
  25. +0 −21 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommandHandler.cs
  26. +0 −9 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommandResult.cs
  27. +0 −17 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/ValidCommand.cs
  28. +8 −7 Solutions/SharpArch.Tests/SharpArch.Domain/DomainModel/BaseObjectEqualityComparerTests.cs
  29. +6 −4 Solutions/SharpArch.Tests/SharpArch.Domain/DomainModel/EntityTests.cs
  30. +0 −7 Solutions/SharpArch.Tests/SharpArch.Tests.csproj
  31. +1 −1 Solutions/SharpArch.Tests/SharpArch.Web.Mvc/ModelBinder/SharpModelBinderTests.cs
  32. +0 −39 Solutions/SharpArch.sln
View
20 Solutions/SharpArch.Domain/Commands/CommandBase.cs
@@ -1,20 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
-
- public class CommandBase : ICommand
- {
- public virtual bool IsValid()
- {
- return ValidationResults().Count == 0;
- }
-
- public virtual ICollection<ValidationResult> ValidationResults()
- {
- var validationResults = new List<ValidationResult>();
- Validator.TryValidateObject(this, new ValidationContext(this, null, null), validationResults, true);
- return validationResults;
- }
- }
-}
View
12 Solutions/SharpArch.Domain/Commands/CommandHandlerNotFoundException.cs
@@ -1,12 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System;
-
- public class CommandHandlerNotFoundException : Exception
- {
- public CommandHandlerNotFoundException(Type type)
- : base(string.Format("Command handler not found for command type: {0}", type))
- {
- }
- }
-}
View
30 Solutions/SharpArch.Domain/Commands/CommandProcessor.cs
@@ -1,30 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
-
- using Microsoft.Practices.ServiceLocation;
-
- public class CommandProcessor : ICommandProcessor
- {
- public ICommandResults Process<TCommand>(TCommand command) where TCommand : ICommand
- {
- Validator.ValidateObject(command, new ValidationContext(command, null, null), true);
-
- var results = new CommandResults();
-
- var handlers = ServiceLocator.Current.GetAllInstances<ICommandHandler<TCommand>>();
- if (handlers == null || !handlers.Any())
- {
- throw new CommandHandlerNotFoundException(typeof(TCommand));
- }
-
- foreach (var result in handlers.Select(handler => handler.Handle(command)))
- {
- results.AddResult(result);
- }
-
- return results;
- }
- }
-}
View
12 Solutions/SharpArch.Domain/Commands/CommandResult.cs
@@ -1,12 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public class CommandResult : ICommandResult
- {
- protected CommandResult(bool success)
- {
- this.Success = success;
- }
-
- public bool Success { get; protected set; }
- }
-}
View
31 Solutions/SharpArch.Domain/Commands/CommandResults.cs
@@ -1,31 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.Linq;
-
- public class CommandResults : ICommandResults
- {
- private readonly List<ICommandResult> results = new List<ICommandResult>();
-
- public bool Success
- {
- get
- {
- return this.results.All(result => result.Success);
- }
- }
-
- public ICommandResult[] Results
- {
- get
- {
- return this.results.ToArray();
- }
- }
-
- public void AddResult(ICommandResult result)
- {
- this.results.Add(result);
- }
- }
-}
View
11 Solutions/SharpArch.Domain/Commands/ICommand.cs
@@ -1,11 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
-
- public interface ICommand
- {
- bool IsValid();
- ICollection<ValidationResult> ValidationResults();
- }
-}
View
7 Solutions/SharpArch.Domain/Commands/ICommandHandler.cs
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandHandler<in TCommand> where TCommand : ICommand
- {
- ICommandResult Handle(TCommand command);
- }
-}
View
7 Solutions/SharpArch.Domain/Commands/ICommandProcessor.cs
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandProcessor
- {
- ICommandResults Process<TCommand>(TCommand command) where TCommand : ICommand;
- }
-}
View
7 Solutions/SharpArch.Domain/Commands/ICommandResult.cs
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandResult
- {
- bool Success { get; }
- }
-}
View
9 Solutions/SharpArch.Domain/Commands/ICommandResults.cs
@@ -1,9 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandResults
- {
- bool Success { get; }
-
- ICommandResult[] Results { get; }
- }
-}
View
2 Solutions/SharpArch.Domain/DomainModel/Entity.cs
@@ -12,7 +12,7 @@
/// than int, such as string, then use <see cref = "EntityWithTypedId{IdT}" /> instead.
/// </summary>
[Serializable]
- public abstract class Entity : EntityWithTypedId<int>
+ public abstract class Entity : EntityWithTypedId<Guid>
{
}
}
View
51 Solutions/SharpArch.Domain/Events/DomainEvents.cs
@@ -1,51 +0,0 @@
-namespace SharpArch.Domain.Events
-{
- using System;
- using System.Collections.Generic;
-
- using Microsoft.Practices.ServiceLocation;
-
- public class DomainEvents
- {
- [ThreadStatic]
- private static List<Delegate> actions;
-
- public static IServiceLocator ServiceLocator { get; set; }
-
- public static void ClearCallbacks()
- {
- actions = null;
- }
-
- public static void Raise<T>(T args) where T : IDomainEvent
- {
- if (ServiceLocator != null)
- {
- foreach (var handler in ServiceLocator.GetAllInstances<IHandles<T>>())
- {
- handler.Handle(args);
- }
- }
-
- if (actions != null)
- {
- foreach (var action in actions)
- {
- if (action is Action<T>)
- {
- ((Action<T>)action)(args);
- }
- }
- }
- }
-
- public static void Register<T>(Action<T> callback) where T : IDomainEvent
- {
- if (actions == null)
- {
- actions = new List<Delegate>();
- }
- actions.Add(callback);
- }
- }
-}
View
6 Solutions/SharpArch.Domain/Events/IDomainEvent.cs
@@ -1,6 +0,0 @@
-namespace SharpArch.Domain.Events
-{
- public interface IDomainEvent
- {
- }
-}
View
7 Solutions/SharpArch.Domain/Events/IHandles.cs
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Events
-{
- public interface IHandles<in T> where T : IDomainEvent
- {
- void Handle(T args);
- }
-}
View
4 Solutions/SharpArch.Domain/PersistenceSupport/IRepository.cs
@@ -1,13 +1,15 @@
namespace SharpArch.Domain.PersistenceSupport
{
+ using System;
+
/// <summary>
/// Provides a standard interface for DAOs which are data-access mechanism agnostic.
///
/// Since nearly all of the domain objects you create will have a type of int Id, this
/// base Idao leverages this assumption. If you want an entity with a type
/// other than int, such as string, then use <see cref = "IRepositoryWithTypedId{T, IdT}" />.
/// </summary>
- public interface IRepository<T> : IRepositoryWithTypedId<T, int>
+ public interface IRepository<T> : IRepositoryWithTypedId<T, Guid>
{
}
}
View
13 Solutions/SharpArch.Domain/SharpArch.Domain.csproj
@@ -78,23 +78,11 @@
<Compile Include="..\..\Common\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="Commands\CommandBase.cs" />
- <Compile Include="Commands\CommandHandlerNotFoundException.cs" />
- <Compile Include="Commands\CommandProcessor.cs" />
- <Compile Include="Commands\CommandResult.cs" />
- <Compile Include="Commands\CommandResults.cs" />
- <Compile Include="Commands\ICommand.cs" />
- <Compile Include="Commands\ICommandHandler.cs" />
- <Compile Include="Commands\ICommandProcessor.cs" />
- <Compile Include="Commands\ICommandResult.cs" />
- <Compile Include="Commands\ICommandResults.cs" />
<Compile Include="DesignByContract\Check.cs" />
<Compile Include="DesignByContract\DesignByContractException.cs" />
<Compile Include="DesignByContract\InvariantException.cs" />
<Compile Include="DesignByContract\PostconditionException.cs" />
<Compile Include="DesignByContract\PreconditionException.cs" />
- <Compile Include="Events\DomainEvents.cs" />
- <Compile Include="Events\IDomainEvent.cs" />
<Compile Include="DomainModel\BaseObject.cs" />
<Compile Include="DesignByContract\AssertionException.cs" />
<Compile Include="DomainModel\BaseObjectEqualityComparer.cs" />
@@ -105,7 +93,6 @@
<Compile Include="DomainModel\IHasAssignedId.cs" />
<Compile Include="DomainModel\ValidatableObject.cs" />
<Compile Include="DomainModel\ValueObject.cs" />
- <Compile Include="Events\IHandles.cs" />
<Compile Include="FileCache.cs" />
<Compile Include="PersistenceSupport\IDbContext.cs" />
<Compile Include="PersistenceSupport\ILinqRepository.cs" />
View
4 Solutions/SharpArch.NHibernate/Contracts/Repositories/INHibernateRepository.cs
@@ -1,5 +1,7 @@
namespace SharpArch.NHibernate.Contracts.Repositories
{
+ using System;
+
using SharpArch.Domain.PersistenceSupport;
/// <summary>
@@ -8,7 +10,7 @@ namespace SharpArch.NHibernate.Contracts.Repositories
/// assembly. For looser coupling, the "Core" layers of the SharpArch library and of your
/// application should not have a reference to the NHibernate assembly.
/// </summary>
- public interface INHibernateRepository<T> : INHibernateRepositoryWithTypedId<T, int>, IRepository<T>
+ public interface INHibernateRepository<T> : INHibernateRepositoryWithTypedId<T, Guid>, IRepository<T>
{
}
}
View
4 Solutions/SharpArch.NHibernate/NHibernateRepository.cs
@@ -1,5 +1,7 @@
namespace SharpArch.NHibernate
{
+ using System;
+
using SharpArch.NHibernate.Contracts.Repositories;
/// <summary>
@@ -8,7 +10,7 @@
/// an entity with a type other than int, such as string, then use
/// <see cref = "NHibernateRepositoryWithTypedId{T, IdT}" />.
/// </summary>
- public class NHibernateRepository<T> : NHibernateRepositoryWithTypedId<T, int>, INHibernateRepository<T>
+ public class NHibernateRepository<T> : NHibernateRepositoryWithTypedId<T, Guid>, INHibernateRepository<T>
{
}
}
View
1 Solutions/SharpArch.Specifications/SharpArch.Domain/DomainModel/EntityWithTypedIdSpecs.cs
@@ -18,7 +18,6 @@ namespace SharpArch.Specifications.SharpArch.Domain.DomainModel
using Machine.Specifications;
- using Tests.SharpArch.Domain;
public class entity_with_type_id_specs
{
View
4 Solutions/SharpArch.Specifications/SharpArch.Specifications.csproj
@@ -95,10 +95,6 @@
<Project>{0BD77F13-8DF6-4C16-9508-33AA4CF0677A}</Project>
<Name>SharpArch.NHibernate</Name>
</ProjectReference>
- <ProjectReference Include="..\SharpArch.Tests\SharpArch.Tests.csproj">
- <Project>{C201296D-09B7-4BAE-96F0-AB59F624DB36}</Project>
- <Name>SharpArch.Tests</Name>
- </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
122 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/CommandProcessorTests.cs
@@ -1,122 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
-
- using Castle.MicroKernel.Registration;
- using Castle.Windsor;
-
- using CommonServiceLocator.WindsorAdapter;
-
- using global::SharpArch.Domain.Commands;
-
- using Microsoft.Practices.ServiceLocation;
-
- using NUnit.Framework;
-
- [TestFixture]
- public class CommandProcessorTests
- {
- private IList<ICommand> _handledCommands;
- private IWindsorContainer _container;
- private ICommandProcessor _commandProcessor;
-
- [SetUp]
- public void SetUp()
- {
- _handledCommands = new List<ICommand>();
- _container = new WindsorContainer();
- ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(_container));
- _commandProcessor = new CommandProcessor();
- }
-
- [TearDown]
- public void TearDown()
- {
- _handledCommands = null;
-
- _commandProcessor = null;
-
- _container.Dispose();
- _container = null;
- }
-
- [Test]
- [ExpectedException(typeof(ValidationException))]
- public void ThrowsIfCommandIsInvalid()
- {
- var testCommand = new InvalidCommand();
- _commandProcessor.Process(testCommand);
- }
-
- [Test]
- [ExpectedException(typeof(ValidationException))]
- public void ThrowsIfCommandIsInvalidButNotRequired()
- {
- var testCommand = new InvalidCommand { Invalid = true };
- _commandProcessor.Process(testCommand);
- }
-
- [Test]
- [ExpectedException(typeof(CommandHandlerNotFoundException))]
- public void ThrowsIfCommandHandlerNotFound()
- {
- var testCommand = new TestCommand();
- _commandProcessor.Process(testCommand);
- }
-
- [Test]
- public void CanHandleSingleCommand()
- {
- _container.Register(
- Component.For<ICommandHandler<TestCommand>>()
- .UsingFactoryMethod(CreateCommandHandler<TestCommand>)
- .LifeStyle.Transient);
-
- var testCommand = new TestCommand();
- _commandProcessor.Process(testCommand);
-
- Assert.AreEqual(1, _handledCommands.Count);
- Assert.AreEqual(testCommand, _handledCommands[0]);
- }
-
- [Test]
- public void CanHandleMultipleCommands()
- {
- _container.Register(
- Component.For<ICommandHandler<TestCommand>>()
- .UsingFactoryMethod(CreateCommandHandler<TestCommand>)
- .Named("First handler")
- .LifeStyle.Transient);
-
- _container.Register(
- Component.For<ICommandHandler<TestCommand>>()
- .UsingFactoryMethod(CreateCommandHandler<TestCommand>)
- .Named("Second handler")
- .LifeStyle.Transient);
-
- var testCommand = new TestCommand();
- var results = _commandProcessor.Process(testCommand);
-
- Assert.AreEqual(2, _handledCommands.Count);
- Assert.AreEqual(testCommand, _handledCommands[0]);
- Assert.AreEqual(testCommand, _handledCommands[1]);
-
- Assert.IsTrue(results.Success);
- Assert.AreEqual(2, results.Results.Length);
- Assert.IsTrue(results.Results[0].Success);
- Assert.IsTrue(results.Results[1].Success);
- }
-
- private TestCommandHandler<TCommand> CreateCommandHandler<TCommand>() where TCommand : ICommand
- {
- return new TestCommandHandler<TCommand>(OnHandle);
- }
-
- private ICommandResult OnHandle<TCommand>(ICommandHandler<TCommand> handler, TCommand command) where TCommand : ICommand
- {
- _handledCommands.Add(command);
- return new TestCommandResult(true);
- }
- }
-}
View
39 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/CommandTests.cs
@@ -1,39 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using NUnit.Framework;
-
- [TestFixture]
- public class CommandTests
- {
- [Test]
- public void IsValidReturnsTrueForValidCommand()
- {
- var command = new ValidCommand();
- Assert.IsTrue(command.IsValid());
- }
-
- [Test]
- public void IsValidReturnsFalseForInvalidCommand()
- {
- var command = new InvalidCommand();
- Assert.IsFalse(command.IsValid());
- }
-
- [Test]
- public void CanGetValidationResultsForInvalidCommand()
- {
- var command = new InvalidCommand();
- var results = command.ValidationResults();
-
- Assert.IsNotNull(results);
- Assert.AreEqual(2, results.Count);
-
- var enumerator = results.GetEnumerator();
- enumerator.MoveNext();
- Assert.AreEqual("The Invalid field is required.", enumerator.Current.ErrorMessage);
-
- enumerator.MoveNext();
- Assert.AreEqual("The field InvalidInt must be between 100 and 199.", enumerator.Current.ErrorMessage);
- }
- }
-}
View
15 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/InvalidCommand.cs
@@ -1,15 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using System.ComponentModel.DataAnnotations;
-
- using global::SharpArch.Domain.Commands;
-
- public class InvalidCommand : CommandBase
- {
- [Required]
- public bool? Invalid { get; set; }
-
- [Range(100, 199)]
- public int InvalidInt { get; set; }
- }
-}
View
9 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommand.cs
@@ -1,9 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using global::SharpArch.Domain.Commands;
-
- public class TestCommand : CommandBase
- {
- public string Data { get; set; }
- }
-}
View
21 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommandHandler.cs
@@ -1,21 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using global::SharpArch.Domain.Commands;
-
- public class TestCommandHandler<TCommand> : ICommandHandler<TCommand> where TCommand : ICommand
- {
- public delegate ICommandResult OnHandle(ICommandHandler<TCommand> handler, TCommand command);
- public event OnHandle OnHandleEvent;
-
- public TestCommandHandler(OnHandle onHandle)
- {
- OnHandleEvent += onHandle;
- }
-
- public ICommandResult Handle(TCommand command)
- {
- var onHandleEvent = OnHandleEvent;
- return onHandleEvent != null ? onHandleEvent(this, command) : null;
- }
- }
-}
View
9 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommandResult.cs
@@ -1,9 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using global::SharpArch.Domain.Commands;
-
- public class TestCommandResult : CommandResult
- {
- public TestCommandResult(bool success) : base(success) {}
- }
-}
View
17 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/ValidCommand.cs
@@ -1,17 +0,0 @@
-namespace Tests.SharpArch.Domain.Commands
-{
- using System.ComponentModel.DataAnnotations;
-
- using global::SharpArch.Domain.Commands;
-
- public class ValidCommand : CommandBase
- {
- public ValidCommand()
- {
- Valid = true;
- }
-
- [Required]
- public bool? Valid { get; set; }
- }
-}
View
15 Solutions/SharpArch.Tests/SharpArch.Domain/DomainModel/BaseObjectEqualityComparerTests.cs
@@ -1,5 +1,6 @@
namespace Tests.SharpArch.Domain.DomainModel
{
+ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -17,20 +18,20 @@ public void CanBeUsedByLinqSetOperatorsSuchAsIntersect()
IList<ConcreteEntityWithDomainSignatureProperties> objects1 =
new List<ConcreteEntityWithDomainSignatureProperties>();
var object1 = new ConcreteEntityWithDomainSignatureProperties { Name = "Billy McCafferty", };
- EntityIdSetter.SetIdOf(object1, 2);
+ EntityIdSetter.SetIdOf(object1, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
objects1.Add(object1);
IList<ConcreteEntityWithDomainSignatureProperties> objects2 =
new List<ConcreteEntityWithDomainSignatureProperties>();
var object2 = new ConcreteEntityWithDomainSignatureProperties { Name = "Jimi Hendrix", };
- EntityIdSetter.SetIdOf(object2, 1);
+ EntityIdSetter.SetIdOf(object2, new Guid("52335ABA-2D8B-4892-A8B7-86B817AAC607"));
objects2.Add(object2);
var object3 = new ConcreteEntityWithDomainSignatureProperties
{
Name =
"Doesn't Matter since the Id will match and the presedence of the domain signature will go overridden",
};
- EntityIdSetter.SetIdOf(object3, 2);
+ EntityIdSetter.SetIdOf(object3, new Guid("52335ABA-2D8B-4892-A8B7-86B817AAC607"));
objects2.Add(object3);
Assert.That(
@@ -72,8 +73,8 @@ public void CanCompareEntitiesWithDomainSignatureProperties()
object2.Name = "Mismatch";
Assert.That(comparer.Equals(object1, object2), Is.False);
- EntityIdSetter.SetIdOf(object1, 1);
- EntityIdSetter.SetIdOf(object2, 1);
+ EntityIdSetter.SetIdOf(object1, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
+ EntityIdSetter.SetIdOf(object2, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
Assert.That(comparer.Equals(object1, object2));
}
@@ -86,8 +87,8 @@ public void CanCompareEntitiesWithNoDomainSignatureProperties()
var object2 = new ConcreteEntityWithNoDomainSignatureProperties { Name = "asdf" };
Assert.That(comparer.Equals(object1, object2), Is.False);
- EntityIdSetter.SetIdOf(object1, 1);
- EntityIdSetter.SetIdOf(object2, 1);
+ EntityIdSetter.SetIdOf(object1, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
+ EntityIdSetter.SetIdOf(object2, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
Assert.That(comparer.Equals(object1, object2));
}
View
10 Solutions/SharpArch.Tests/SharpArch.Domain/DomainModel/EntityTests.cs
@@ -1,5 +1,7 @@
namespace Tests.SharpArch.Domain.DomainModel
{
+ using System;
+
using global::SharpArch.Domain.DomainModel;
using NUnit.Framework;
@@ -98,8 +100,8 @@ public void CanCompareEntitys()
Assert.That(object1, Is.Not.EqualTo(null));
Assert.That(object1, Is.Not.EqualTo(object2));
- EntityIdSetter.SetIdOf(object1, 10);
- EntityIdSetter.SetIdOf(object2, 10);
+ EntityIdSetter.SetIdOf(object1, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
+ EntityIdSetter.SetIdOf(object2, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
// Even though the "business value signatures" are different, the persistent Ids
// were the same. Call me crazy, but I put that much trust into persisted Ids.
@@ -199,8 +201,8 @@ public void CannotEquateObjectsWithSameIdButDifferentTypes()
var object1Type = new Object1();
var object2Type = new Object2();
- EntityIdSetter.SetIdOf(object1Type, 1);
- EntityIdSetter.SetIdOf(object2Type, 1);
+ EntityIdSetter.SetIdOf(object1Type, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
+ EntityIdSetter.SetIdOf(object2Type, new Guid("79E9F560-FD70-4807-BEED-50A87AA911B1"));
Assert.That(object1Type, Is.Not.EqualTo(object2Type));
}
View
7 Solutions/SharpArch.Tests/SharpArch.Tests.csproj
@@ -136,13 +136,6 @@
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="SharpArch.Domain\Commands\CommandProcessorTests.cs" />
- <Compile Include="SharpArch.Domain\Commands\CommandTests.cs" />
- <Compile Include="SharpArch.Domain\Commands\InvalidCommand.cs" />
- <Compile Include="SharpArch.Domain\Commands\TestCommand.cs" />
- <Compile Include="SharpArch.Domain\Commands\TestCommandHandler.cs" />
- <Compile Include="SharpArch.Domain\Commands\TestCommandResult.cs" />
- <Compile Include="SharpArch.Domain\Commands\ValidCommand.cs" />
<Compile Include="SharpArch.Domain\DataAnnotationsValidator\HasUniqueEntitySignatureValidatorTests.cs" />
<Compile Include="SharpArch.Domain\DesignByContractTests.cs" />
<Compile Include="SharpArch.Domain\DomainModel\BaseObjectEqualityComparerTests.cs" />
View
2 Solutions/SharpArch.Tests/SharpArch.Web.Mvc/ModelBinder/SharpModelBinderTests.cs
@@ -253,7 +253,7 @@ public Employee()
this.Reports = new List<Employee>();
}
- public Employee(int id)
+ public Employee(Guid id)
{
this.Id = id;
}
View
39 Solutions/SharpArch.sln
@@ -5,10 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.Domain", "SharpAr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.Web.Mvc", "SharpArch.Web.Mvc\SharpArch.Web.Mvc.csproj", "{BF4E3D18-2EFB-49E3-9D8D-0F9F9BE1094A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.Tests", "SharpArch.Tests\SharpArch.Tests.csproj", "{C201296D-09B7-4BAE-96F0-AB59F624DB36}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.Testing.NUnit", "SharpArch.Testing.NUnit\SharpArch.Testing.NUnit.csproj", "{D6DDE603-4678-44B9-A2D1-101BF5D12AD7}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.Wcf", "SharpArch.Wcf\SharpArch.Wcf.csproj", "{F7F5E614-3B4E-43EC-8F8A-CB46B89A3827}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.WcfClient.Castle", "SharpArch.WcfClient.Castle\SharpArch.WcfClient.Castle.csproj", "{A3B21E07-F25F-46D3-B4DE-EA29A0A4A831}"
@@ -35,8 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{ED61719A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{D5220D0A-6367-41C4-8409-989C4A909113}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.RavenDb", "SharpArch.RavenDb\SharpArch.RavenDb.csproj", "{B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpArch.NHibernate", "SharpArch.NHibernate\SharpArch.NHibernate.csproj", "{0BD77F13-8DF6-4C16-9508-33AA4CF0677A}"
EndProject
Global
@@ -69,26 +63,6 @@ Global
{BF4E3D18-2EFB-49E3-9D8D-0F9F9BE1094A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BF4E3D18-2EFB-49E3-9D8D-0F9F9BE1094A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BF4E3D18-2EFB-49E3-9D8D-0F9F9BE1094A}.Release|x86.ActiveCfg = Release|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Debug|x86.ActiveCfg = Debug|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Release|Any CPU.Build.0 = Release|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {C201296D-09B7-4BAE-96F0-AB59F624DB36}.Release|x86.ActiveCfg = Release|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Debug|x86.ActiveCfg = Debug|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Release|Any CPU.Build.0 = Release|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7}.Release|x86.ActiveCfg = Release|Any CPU
{F7F5E614-3B4E-43EC-8F8A-CB46B89A3827}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7F5E614-3B4E-43EC-8F8A-CB46B89A3827}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7F5E614-3B4E-43EC-8F8A-CB46B89A3827}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -119,16 +93,6 @@ Global
{CB7976A2-5089-4AC8-83C3-24FAB6F50ED4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CB7976A2-5089-4AC8-83C3-24FAB6F50ED4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CB7976A2-5089-4AC8-83C3-24FAB6F50ED4}.Release|x86.ActiveCfg = Release|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Debug|x86.ActiveCfg = Debug|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Release|Any CPU.Build.0 = Release|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC}.Release|x86.ActiveCfg = Release|Any CPU
{0BD77F13-8DF6-4C16-9508-33AA4CF0677A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BD77F13-8DF6-4C16-9508-33AA4CF0677A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BD77F13-8DF6-4C16-9508-33AA4CF0677A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -147,11 +111,8 @@ Global
{E12E99BB-8732-441F-B3A6-861F0CE23D3D} = {C17FF2BE-F51B-49EA-9670-92CD4531B4D1}
{F7F5E614-3B4E-43EC-8F8A-CB46B89A3827} = {C3FCEC2B-1A32-4AA3-8989-69559CFF568B}
{BF4E3D18-2EFB-49E3-9D8D-0F9F9BE1094A} = {C3FCEC2B-1A32-4AA3-8989-69559CFF568B}
- {D6DDE603-4678-44B9-A2D1-101BF5D12AD7} = {5029AAB4-E60E-4C71-8D40-9812DDBB4253}
- {C201296D-09B7-4BAE-96F0-AB59F624DB36} = {5029AAB4-E60E-4C71-8D40-9812DDBB4253}
{A3B21E07-F25F-46D3-B4DE-EA29A0A4A831} = {8086F206-D8C3-4D8B-968C-A5EF3BA79D12}
{CB7976A2-5089-4AC8-83C3-24FAB6F50ED4} = {8C1A5B2F-1EE3-4A27-A650-044905607028}
- {B556850E-2EE3-4D1E-9A56-1D7C7C1C95EC} = {D5220D0A-6367-41C4-8409-989C4A909113}
{0BD77F13-8DF6-4C16-9508-33AA4CF0677A} = {D5220D0A-6367-41C4-8409-989C4A909113}
EndGlobalSection
EndGlobal

0 comments on commit 2ee9f36

Please sign in to comment.
Something went wrong with that request. Please try again.