Permalink
Browse files

Moving from RhinoMocks to FakeItEasy

  • Loading branch information...
1 parent 2cadff4 commit b779ae19dc4cfc3167b781b399f3cb6ec87d56a7 @twiernik twiernik committed Dec 15, 2013
Showing with 286 additions and 371 deletions.
  1. +4 −4 src/FluentNHibernate.Testing/AutoMapping/Apm/AlterationTests.cs
  2. +2 −1 src/FluentNHibernate.Testing/Cfg/MappingConfigurationTests.cs
  3. +46 −48 src/FluentNHibernate.Testing/ConventionsTests/ProxyConventionTester.cs
  4. +12 −9 src/FluentNHibernate.Testing/Diagnostics/DiagnosticConfigurationTests.cs
  5. +45 −72 src/FluentNHibernate.Testing/Diagnostics/DiagnosticLoggerTests.cs
  6. +5 −5 src/FluentNHibernate.Testing/Diagnostics/DiagnosticMessageDespatcherTests.cs
  7. +5 −6 src/FluentNHibernate.Testing/Diagnostics/StringLambdaOutputListenerTests.cs
  8. +0 −1 src/FluentNHibernate.Testing/DomainModel/Mapping/CascadeExpressionTester.cs
  9. +5 −6 src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj
  10. +19 −21 src/FluentNHibernate.Testing/MappingModel/ClassMappingTester.cs
  11. +10 −6 src/FluentNHibernate.Testing/MappingModel/HibernateMappingTester.cs
  12. +0 −1 src/FluentNHibernate.Testing/MappingModel/Output/XmlCompositeElementWriterTester.cs
  13. +3 −12 src/FluentNHibernate.Testing/Specification.cs
  14. +19 −19 src/FluentNHibernate.Testing/Testing/PersistenceSpecificationExtensionsSpecs.cs
  15. +20 −20 src/FluentNHibernate.Testing/Testing/PersistenceSpecificationTester.cs
  16. +26 −34 src/FluentNHibernate.Testing/Testing/PersistenceSpecificationTransactionTest.cs
  17. +24 −26 src/FluentNHibernate.Testing/Testing/Values/ListSpecs.cs
  18. +14 −13 src/FluentNHibernate.Testing/Testing/Values/PropertySpecs.cs
  19. +6 −5 src/FluentNHibernate.Testing/Testing/Values/ReferenceListSpecs.cs
  20. +5 −4 src/FluentNHibernate.Testing/Testing/Values/ReferencePropertySpecs.cs
  21. +0 −22 src/FluentNHibernate.Testing/Utils/Mock.cs
  22. +0 −22 src/FluentNHibernate.Testing/Utils/Stub.cs
  23. +15 −13 src/FluentNHibernate.Testing/Visitors/ComponentReferenceResolutionVisitorSpecs.cs
  24. +1 −1 src/FluentNHibernate.Testing/packages.config
@@ -1,8 +1,8 @@
-using FluentNHibernate.Automapping;
+using FakeItEasy;
+using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using FluentNHibernate.Automapping.TestFixtures;
using NUnit.Framework;
-using Rhino.Mocks;
namespace FluentNHibernate.Testing.Automapping.Apm
{
@@ -21,13 +21,13 @@ public void CreateAutoMapper()
[Test]
public void ShouldApplyAlterationsToModel()
{
- var alteration = MockRepository.GenerateMock<IAutoMappingAlteration>();
+ var alteration = A.Fake<IAutoMappingAlteration>();
model
.Alterations(alterations => alterations.Add(alteration))
.BuildMappings();
- alteration.AssertWasCalled(x => x.Alter(model));
+ A.CallTo(() => alteration.Alter(model)).MustHaveHappened();
}
[Test]
@@ -1,4 +1,5 @@
using System.Linq;
+using FakeItEasy;
using FluentNHibernate.Automapping;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
@@ -22,7 +23,7 @@ public class MappingConfigurationTests
[SetUp]
public void CreateMappingConfiguration()
{
- logger = Stub<IDiagnosticLogger>.Create();
+ logger = A.Fake<IDiagnosticLogger>();
cfg = new Configuration();
SQLiteConfiguration.Standard
@@ -2,13 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using FakeItEasy;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using FluentNHibernate.Mapping;
using FluentNHibernate.MappingModel;
using NUnit.Framework;
-using Rhino.Mocks;
namespace FluentNHibernate.Testing.ConventionsTests
{
@@ -20,147 +20,145 @@ public void ConventionSetsProxyOnProxiedClass()
{
ProxyConvention convention = GetConvention();
- var classInstance = MockRepository.GenerateMock<IClassInstance>();
- classInstance.Expect(x => x.EntityType)
- .Return(typeof(ProxiedObject));
-
+ var classInstance = A.Fake<IClassInstance>();
+ A.CallTo(() => classInstance.EntityType).Returns(typeof(ProxiedObject));
+
convention.Apply(classInstance);
- classInstance.AssertWasCalled(x => x.Proxy(typeof(IProxiedObject)));
+ A.CallTo(() => classInstance.Proxy(typeof(IProxiedObject)))
+ .MustHaveHappened();
}
[Test]
public void ConventionSetsProxyOnProxiedSubclass()
{
ProxyConvention convention = GetConvention();
- var classInstance = MockRepository.GenerateMock<ISubclassInstance>();
- classInstance.Expect(x => x.EntityType)
- .Return(typeof(ProxiedObject));
+ var classInstance = A.Fake<ISubclassInstance>();
+ A.CallTo(() => classInstance.EntityType).Returns(typeof(ProxiedObject));
convention.Apply(classInstance);
- classInstance.AssertWasCalled(x => x.Proxy(typeof(IProxiedObject)));
+ A.CallTo(() => classInstance.Proxy(typeof(IProxiedObject)))
+ .MustHaveHappened();
}
[Test]
public void ConventionDoesNotSetProxyOnUnproxiedClass()
{
ProxyConvention convention = GetConvention();
- var classInstance = MockRepository.GenerateMock<IClassInstance>();
- classInstance.Stub(x => x.EntityType)
- .Return(typeof(NotProxied));
+ var classInstance = A.Fake<IClassInstance>();
+ A.CallTo(() => classInstance.EntityType).Returns(typeof(NotProxied));
convention.Apply(classInstance);
- classInstance.AssertWasNotCalled(x => x.Proxy(Arg<Type>.Is.Anything));
+ A.CallTo(() => classInstance.Proxy(A<Type>._)).MustNotHaveHappened();
}
[Test]
public void ConventionDoesNotSetProxyOnUnproxiedSubclass()
{
ProxyConvention convention = GetConvention();
- var classInstance = MockRepository.GenerateMock<ISubclassInstance>();
- classInstance.Stub(x => x.EntityType)
- .Return(typeof(NotProxied));
+ var classInstance = A.Fake<ISubclassInstance>();
+ A.CallTo(() => classInstance.EntityType).Returns(typeof(NotProxied));
convention.Apply(classInstance);
- classInstance.AssertWasNotCalled(x => x.Proxy(Arg<Type>.Is.Anything));
+ A.CallTo(() => classInstance.Proxy(A<Type>._)).MustNotHaveHappened();
}
[Test]
public void ConventionSetsProxiedCollectionChildTypeToConcreteType()
{
ProxyConvention convention = GetConvention();
- var collectionInstance = MockRepository.GenerateMock<ICollectionInstance>();
- var relationship = MockRepository.GenerateMock<IRelationshipInstance>();
+ var collectionInstance = A.Fake<ICollectionInstance>();
+ var relationship = A.Fake<IRelationshipInstance>();
- collectionInstance.Stub(x => x.Relationship)
- .Return(relationship);
- relationship.Stub(x => x.Class)
- .Return(new TypeReference(typeof(IProxiedObject)));
+ A.CallTo(() => collectionInstance.Relationship).Returns(relationship);
+ A.CallTo(() => relationship.Class).Returns(new TypeReference(typeof(IProxiedObject)));
convention.Apply(collectionInstance);
- relationship.AssertWasCalled(x => x.CustomClass(typeof(ProxiedObject)));
+ A.CallTo(() => relationship.CustomClass(typeof(ProxiedObject)))
+ .MustHaveHappened();
}
[Test]
public void ConventionDoesNotSetCollectionChildTypeIfUnrecognised()
{
ProxyConvention convention = GetConvention();
- var collectionInstance = MockRepository.GenerateMock<ICollectionInstance>();
- var relationship = MockRepository.GenerateMock<IRelationshipInstance>();
+ var collectionInstance = A.Fake<ICollectionInstance>();
+ var relationship = A.Fake<IRelationshipInstance>();
- collectionInstance.Stub(x => x.Relationship)
- .Return(relationship);
- relationship.Stub(x => x.Class)
- .Return(new TypeReference(typeof(NotProxied)));
+ A.CallTo(() => collectionInstance.Relationship).Returns(relationship);
+ A.CallTo(() => relationship.Class).Returns(new TypeReference(typeof(NotProxied)));
convention.Apply(collectionInstance);
- relationship.AssertWasNotCalled(x => x.CustomClass(Arg<Type>.Is.Anything));
+ A.CallTo(() => relationship.CustomClass(A<Type>._))
+ .MustNotHaveHappened();
}
[Test]
public void ConventionSetsProxiedManyToOneTypeToConcreteType()
{
ProxyConvention convention = GetConvention();
- var manyToOneInstance = MockRepository.GenerateMock<IManyToOneInstance>();
- manyToOneInstance.Stub(x => x.Class)
- .Return(new TypeReference(typeof(IProxiedObject)));
+ var manyToOneInstance = A.Fake<IManyToOneInstance>();
+ A.CallTo(() => manyToOneInstance.Class).Returns(new TypeReference(typeof(IProxiedObject)));
convention.Apply(manyToOneInstance);
- manyToOneInstance.AssertWasCalled(x => x.OverrideInferredClass(typeof(ProxiedObject)));
+ A.CallTo(() => manyToOneInstance.OverrideInferredClass(typeof(ProxiedObject)))
+ .MustHaveHappened();
}
[Test]
public void ConventionDoesNotSetManyToOneTypeIfUnrecognised()
{
ProxyConvention convention = GetConvention();
- var manyToOneInstance = MockRepository.GenerateMock<IManyToOneInstance>();
- manyToOneInstance.Stub(x => x.Class)
- .Return(new TypeReference(typeof(NotProxied)));
+ var manyToOneInstance = A.Fake<IManyToOneInstance>();
+ A.CallTo(() => manyToOneInstance.Class).Returns(new TypeReference(typeof(NotProxied)));
convention.Apply(manyToOneInstance);
- manyToOneInstance.AssertWasNotCalled(x => x.OverrideInferredClass(typeof(ProxiedObject)));
+ A.CallTo(() => manyToOneInstance.OverrideInferredClass(typeof(ProxiedObject)))
+ .MustNotHaveHappened();
}
[Test]
public void ConventionSetsProxiedOneToOneTypeToConcreteType()
{
ProxyConvention convention = GetConvention();
- var oneToOneInstance = MockRepository.GenerateMock<IOneToOneInstance>();
- oneToOneInstance.Stub(x => ((IOneToOneInspector)x).Class)
- .Return(new TypeReference(typeof(IProxiedObject)));
+ var oneToOneInstance = A.Fake<IOneToOneInstance>();
+ A.CallTo(() => ((IOneToOneInspector)oneToOneInstance).Class)
+ .Returns(new TypeReference(typeof(IProxiedObject)));
convention.Apply(oneToOneInstance);
- oneToOneInstance.AssertWasCalled(x => x.OverrideInferredClass(typeof(ProxiedObject)));
+ A.CallTo(() => oneToOneInstance.OverrideInferredClass(typeof(ProxiedObject)))
+ .MustHaveHappened();
}
[Test]
public void ConventionDoesNotSetOneToOneTypeIfUnrecognised()
{
ProxyConvention convention = GetConvention();
- var oneToOneInstance = MockRepository.GenerateMock<IOneToOneInstance>();
- oneToOneInstance.Stub(x => ((IOneToOneInspector)x).Class)
- .Return(new TypeReference(typeof(NotProxied)));
+ var oneToOneInstance = A.Fake<IOneToOneInstance>();
+ A.CallTo(() => ((IOneToOneInspector)oneToOneInstance).Class)
+ .Returns(new TypeReference(typeof(NotProxied)));
convention.Apply(oneToOneInstance);
- oneToOneInstance.AssertWasNotCalled(x => x.OverrideInferredClass(typeof(ProxiedObject)));
+ A.CallTo(() => oneToOneInstance.OverrideInferredClass(typeof(ProxiedObject)))
+ .MustNotHaveHappened();
}
private static ProxyConvention GetConvention()
@@ -1,7 +1,7 @@
-using FluentNHibernate.Diagnostics;
+using FakeItEasy;
+using FluentNHibernate.Diagnostics;
using FluentNHibernate.Testing.Utils;
using NUnit.Framework;
-using Rhino.Mocks;
namespace FluentNHibernate.Testing.Diagnostics
{
@@ -33,35 +33,38 @@ public void disabling_should_set_logger_to_null_impl()
[Test]
public void adding_listener_should_add_listener_to_underlying_dispatcher()
{
- var dispatcher = Mock<IDiagnosticMessageDispatcher>.Create();
- var listener = Stub<IDiagnosticListener>.Create();
+ var dispatcher = A.Fake<IDiagnosticMessageDispatcher>();
+ var listener = A.Fake<IDiagnosticListener>();
new DiagnosticsConfiguration(dispatcher, l => { })
.RegisterListener(listener);
- dispatcher.AssertWasCalled(x => x.RegisterListener(listener));
+ A.CallTo(() => dispatcher.RegisterListener(listener))
+ .MustHaveHappened();
}
[Test]
public void output_to_console_should_register_console_listener()
{
- var dispatcher = Mock<IDiagnosticMessageDispatcher>.Create();
+ var dispatcher = A.Fake<IDiagnosticMessageDispatcher>();
new DiagnosticsConfiguration(dispatcher, l => { })
.OutputToConsole();
- dispatcher.AssertWasCalled(x => x.RegisterListener(Arg<ConsoleOutputListener>.Is.TypeOf));
+ A.CallTo(() => dispatcher.RegisterListener(A<ConsoleOutputListener>._))
+ .MustHaveHappened();
}
[Test]
public void output_to_file_should_register_console_listener()
{
- var dispatcher = Mock<IDiagnosticMessageDispatcher>.Create();
+ var dispatcher = A.Fake<IDiagnosticMessageDispatcher>();
new DiagnosticsConfiguration(dispatcher, l => { })
.OutputToFile("path");
- dispatcher.AssertWasCalled(x => x.RegisterListener(Arg<FileOutputListener>.Is.TypeOf));
+ A.CallTo(() => dispatcher.RegisterListener(A<FileOutputListener>._))
+ .MustHaveHappened();
}
}
}
Oops, something went wrong.

2 comments on commit b779ae1

Collaborator

chester89 replied Dec 16, 2013

TeamCity Fluent NHibernate :: Regular build Build 1.3.6.102 is now running

Collaborator

chester89 replied Dec 16, 2013

TeamCity Fluent NHibernate :: Regular build Build 1.3.6.102 outcome was SUCCESS
Summary: Tests passed: 3343, ignored: 20 Build time: 0:3:26

Please sign in to comment.