public void ShouldBeAbleToIgnoreLemmingsFromAssemblyUsingNonGenericIgnore() { ConfigureIoC(typeof(Service), typeof(ServiceDependency), typeof(ServiceWithGenericDependency), typeof(GenericService <string>), typeof(NamedLemming), typeof(LemmingWithValuesFromConfiguration), typeof(LemmingWithValuesFromConfigurationWithOverridenKey), typeof(NoSingletonLemming), typeof(LemmingWithStaticInjection), typeof(LemmingsCollection <IServiceDependency>), typeof(NullObjectFactory), typeof(ConcreteLemming), typeof(NullUnitOfWork), typeof(TestSingletonPresenter)); Nails.Configure() .IoC.Container(iocContainer) .Lemming <NullObjectFactory>() .Lemming <NullUnitOfWork>() .Lemming(typeof(TestPresenter), x => x.Ignore()) .InspectAssembly("Nails.Tests.dll") .Initialize(configureDefaults: false); objectFactory.VerifyAllExpectations(); }
private static void RequireUnitOfWorkForAccessingSessionContext() { Nails.Configure().Aspects .ApplyBehavior <RunningUnitOfWorkValidationBehavior>() .ExcludingMethods("Dispose") .ToInheritorsOf <ISessionContext>(); }
private static void Default <TInterface, TImplementation>() where TImplementation : class, TInterface { if (!Nails.Configuration.LemmingsSchema.Any(x => typeof(TInterface).IsAssignableFrom(x.ConcreteType))) { Nails.Configure().IoC.Lemming <TImplementation>(); } }
public void InspectAssembliesByTypes() { Nails.Configure().InspectAssemblyOf <ConfigurationTests>() .InspectAssemblyOf <NailsConfiguration>(); Assert.AreEqual(2, Nails.Configuration.AssembliesToInspect.Count()); }
public void ShouldNotLetConfigureNailsOnceInitialized() { Nails.Configure() .Initialize(); Assert.Throws <InvalidOperationException>(() => Nails.Configure()); }
public void InspectAssemblies() { Nails.Configure().InspectAssembly(GetType().Assembly) .InspectAssembly(typeof(Nails).Assembly); Assert.AreEqual(2, Nails.Configuration.AssembliesToInspect.Count()); }
public void InspectAssembliesByName() { Nails.Configure().InspectAssembly("Nails.Tests.dll") .InspectAssembly("Nails.dll"); Assert.AreEqual(2, Nails.Configuration.AssembliesToInspect.Count()); }
public void AttributeShouldUseConfigurationTransactionMode() { Nails.Configure().UnitOfWork.DefaultTransactionMode(TransactionMode.NoTransaction); var info = UnitOfWorkInfo.From(GetType().GetMethod("MethodWithDefaultUnitOfWorkAttribute")); Assert.IsFalse(info.IsTransactional); }
public ReferenceResolver AcquireConfiguration(NailsTestsConfigurable test) { rwLock.AcquireReaderLock(ConfigurationTimeout); var testConfigurationName = test.ConfigurationName; if (currentConfigurationName != testConfigurationName) { var lockCookie = rwLock.UpgradeToWriterLock(ConfigurationTimeout); try { var configurationDelegate = NailsTestsConfigurationRepository.Instance.Get(testConfigurationName); Nails.Reset(); configurationDelegate(Nails.Configure().UnitOfWork.ConnectionBoundUnitOfWork(false)); currentReferenceResolver = new ReferenceResolver(Nails.ObjectFactory); currentConfigurationName = testConfigurationName; } finally { rwLock.DowngradeFromWriterLock(ref lockCookie); } } return(currentReferenceResolver); }
public void SetUp() { mocks = new MockRepository(); failureCall = false; successCall = false; Nails.Configure() .IoC.Container <NullIoCContainer>() .Initialize(); workContextProvider = mocks.DynamicMock <IWorkContextProvider>(); var persistenceContext = mocks.DynamicMock <IPersistenceContext>(); transactionalContext = mocks.DynamicMock <ITransactionalContext>(); persistenceContext.Expect(x => x.CreateTransactionalContext()).Return(transactionalContext); workContext = new WorkContext(persistenceContext); workContextProvider.Expect(x => x.CurrentContext).Return(workContext).Repeat.Any(); currentUnitOfWork = new CurrentUnitOfWork { WorkContextProvider = workContextProvider }; }
public void ShouldCohexistSeveralInstancesWithDifferentViewsInDifferentExecutionContexts() { Nails.Reset(false); Nails.Configure() .IoC.Container <NailsFramework.IoC.Spring>() .Lemming <TestSingletonPresenter>() .Lemming <SwitcheableExcecutionContext>() .UserInterface.Platform <NullMvp>() .Initialize(); var context = Nails.ObjectFactory.GetObject <SwitcheableExcecutionContext>(); var view1 = new TestSingletonView(); var view2 = new TestSingletonView(); context.SwitchToA(); var presenter1 = PresenterProvider.GetFor(view1); context.SwitchToB(); var presenter2 = PresenterProvider.GetFor(view2); Assert.AreSame(presenter1, presenter2); context.SwitchToA(); Assert.AreEqual(presenter1.GetView(), view1); context.SwitchToB(); Assert.AreEqual(presenter2.GetView(), view2); }
public void OnConfigurationErrorShouldThrowException() { DataMapper dataMapper = CreateDataMapper(); dataMapper.Expect(x => x.Initialize()).Throw(new Exception()); Nails.Configure().Persistence.DataMapper(dataMapper).Initialize(); }
public void ShouldDoNothing() { new NullObjectTester().Test <ILog>(new NullLog()); var logger = new NullLogger(); logger.AddCustomConfiguration(Nails.Configure()); logger.Initialize(); }
public void ShouldAddStaticReferencesByAttributesWhenAddingAssemblies() { Nails.Configure() .InspectAssembly("Nails.Tests.dll") .Initialize(configureDefaults: false); Assert.AreEqual(8, Nails.Configuration.StaticInjections.Count()); }
public void Reset() { Nails.Reset(false); if (UseTestContext) { Nails.Configure().IoC.Lemming <TestExecutionContext>(); } }
public void UnitOfWorkBehavior() { Nails.Configure().UserInterface.Platform <NullMvp>() .Initialize(configureDefaults: false); var aspects = Nails.Configuration.Aspects; Assert.That(aspects.Any(x => x.Behavior is UnitOfWorkBehavior && x.AppliesTo(testMethod))); }
public void ShouldSetBehaviorToAspect() { Nails.Configure() .Aspects.ApplyBehavior <NullBehavior>().ToInheritorsOf <IList <string> >(); var aspect = Nails.Configuration.Aspects.Single(); Assert.IsInstanceOf <NullBehavior>(aspect.Behavior); }
public void FromMethodWithAllowAsyncAttribute() { Nails.Configure().UnitOfWork.DefaultAsyncMode(false) .AllowAsyncExecution(true); var info = UnitOfWorkInfo.From(GetType().GetMethod("AsyncMethod")); Assert.IsTrue(info.IsAsync); }
public void OnConfigurationErrorShouldAddMissingConfiguration() { DataMapper dataMapper = CreateDataMapper(); dataMapper.Expect(x => x.Initialize()).Throw(new Exception()); Assert.Throws <Exception>(() => Nails.Configure().Persistence.DataMapper(dataMapper).Initialize()); CollectionAssert.IsNotEmpty(Nails.Status.MissingConfigurations); }
public void OnConfigurationErrorShouldNotBeReady() { DataMapper dataMapper = CreateDataMapper(); dataMapper.Expect(x => x.Initialize()).Throw(new Exception()); Assert.Throws <Exception>(() => Nails.Configure().Persistence.DataMapper(dataMapper).Initialize()); Assert.IsFalse(Nails.Status.IsReady); }
public void FromMethodShouldNotBeAsyncByDefaultIfDefaultIsNotAsync() { Nails.Configure().UnitOfWork.DefaultAsyncMode(false) .AllowAsyncExecution(true); var info = UnitOfWorkInfo.From(GetType().GetMethod("MethodWithoutAttributes")); Assert.IsFalse(info.IsAsync); }
public void ShouldIgnoreWithAllowAsyncAttributeIfAsyncExecutionIsNotAllowed() { Nails.Configure().UnitOfWork.DefaultAsyncMode(false) .AllowAsyncExecution(false); var info = UnitOfWorkInfo.From(GetType().GetMethod("AsyncMethod")); Assert.IsFalse(info.IsAsync); }
public void ShouldNotBeAsyncByDefaultIfDefaultIsNotAsync() { Nails.Configure().UnitOfWork.DefaultAsyncMode(true) .AllowAsyncExecution(true); var info = new UnitOfWorkInfo(); Assert.IsFalse(info.IsAsync); }
public void ShouldIgnoreDefaultIfNotFromMethod() { Nails.Configure().UnitOfWork.DefaultAsyncMode(true) .AllowAsyncExecution(true); var info = new UnitOfWorkInfo(); Assert.IsFalse(info.IsAsync); }
public void AssembliesToInspect() { Nails.Configure().InspectAssembly("Nails.Tests.dll") .InspectAssembly("Nails.dll"); var assembliesToInspect = new AssembliesToInspect(); Assert.AreEqual(2, assembliesToInspect.Count()); }
public void SetUp() { Nails.Reset(false); Nails.Configure() .IoC.Container <NailsFramework.IoC.Spring>() .Initialize(); sessionContext = Nails.ObjectFactory.GetObject <ISessionContext>(); }
public void ShouldFailIfConfiguringAReferenceToANonExistingLemming() { ConfigureIoC(typeof(Service)); Nails.Configure() .IoC.Container(iocContainer) .Lemming <Service>(); Assert.Throws <InvalidOperationException>(() => Nails.Configure().Initialize(configureDefaults: false)); }
public void ConfigureNails() { Nails.Configure() .IoC.Container(IoCContainers.GetContainer(ioc)) .Lemming <ServiceDependency>() .Lemming <Service>() .Persistence.DataMapper <NailsFramework.Persistence.NHibernate>() .UserInterface.Platform <NullMvp>() .Initialize(); }
public void SetUp() { objectFactory = MockRepository.GenerateMock <IConfigurableObjectFactory>(); var iocProvider = MockRepository.GenerateMock <IoCContainer>(); iocProvider.Expect(x => x.GetObjectFactory()).Return(objectFactory).Repeat.Any(); Nails.Configure().IoC.Container(iocProvider).Initialize(); injector = new StaticInjector(objectFactory); }
public void AspectsForPresenterMethodsExceptSetView() { Nails.Configure().UserInterface.Platform <NullMvp>() .Initialize(configureDefaults: false); var aspects = Nails.Configuration.Aspects; Assert.That(aspects.All(x => x.AppliesTo(testMethod))); Assert.That(aspects.All(x => !x.AppliesTo(setViewMethod))); }