public void CanExportFromFactoryObjectIfObjectTypeIsInterface() { using (DefaultListableObjectFactory of = new DefaultListableObjectFactory()) { MockRepository mocks = new MockRepository(); IFactoryObject simpleCounterFactory = (IFactoryObject)mocks.DynamicMock(typeof(IFactoryObject)); Expect.Call(simpleCounterFactory.ObjectType).Return(typeof(ISimpleCounter)); Expect.Call(simpleCounterFactory.IsSingleton).Return(true); Expect.Call(simpleCounterFactory.GetObject()).Return(new SimpleCounter()); mocks.ReplayAll(); of.RegisterSingleton("simpleCounter", simpleCounterFactory); SaoExporter saoExporter = new SaoExporter(); saoExporter.ObjectFactory = of; saoExporter.TargetName = "simpleCounter"; saoExporter.ServiceName = "RemotedSaoCallCounter"; saoExporter.AfterPropertiesSet(); of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()! AssertExportedService(saoExporter.ServiceName, 2); mocks.VerifyAll(); } }
public void BailsIfTargetNotFound() { using (DefaultListableObjectFactory of = new DefaultListableObjectFactory()) { SaoExporter saoExporter = new SaoExporter(); saoExporter.ObjectFactory = of; saoExporter.TargetName = "DOESNOTEXIST"; saoExporter.ServiceName = "RemotedSaoSingletonCounter"; saoExporter.AfterPropertiesSet(); } }
public void ExportSingleton() { using (DefaultListableObjectFactory of = new DefaultListableObjectFactory()) { of.RegisterSingleton("simpleCounter", new SimpleCounter()); SaoExporter saoExporter = new SaoExporter(); saoExporter.ObjectFactory = of; saoExporter.TargetName = "simpleCounter"; saoExporter.ServiceName = "RemotedSaoSingletonCounter"; saoExporter.AfterPropertiesSet(); of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()! AssertExportedService(saoExporter.ServiceName, 2); } }
public void ExportSingleCall() { using (DefaultListableObjectFactory of = new DefaultListableObjectFactory()) { of.RegisterObjectDefinition("simpleCounter", new RootObjectDefinition(typeof(SimpleCounter), false)); SaoExporter saoExporter = new SaoExporter(); saoExporter.ObjectFactory = of; saoExporter.TargetName = "simpleCounter"; saoExporter.ServiceName = "RemotedSaoSingleCallCounter"; saoExporter.AfterPropertiesSet(); of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()! AssertExportedService(saoExporter.ServiceName, 0); } }
public void CanExportFromFactoryObjectIfObjectTypeIsInterface() { using (DefaultListableObjectFactory of = new DefaultListableObjectFactory()) { IFactoryObject simpleCounterFactory = A.Fake <IFactoryObject>(); A.CallTo(() => simpleCounterFactory.ObjectType).Returns(typeof(ISimpleCounter)); A.CallTo(() => simpleCounterFactory.IsSingleton).Returns(true); A.CallTo(() => simpleCounterFactory.GetObject()).Returns(new SimpleCounter()); of.RegisterSingleton("simpleCounter", simpleCounterFactory); SaoExporter saoExporter = new SaoExporter(); saoExporter.ObjectFactory = of; saoExporter.TargetName = "simpleCounter"; saoExporter.ServiceName = "RemotedSaoCallCounter"; saoExporter.AfterPropertiesSet(); of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()! AssertExportedService(saoExporter.ServiceName, 2); } }
public void BailsWhenNotConfigured() { SaoExporter exp = new SaoExporter(); exp.AfterPropertiesSet(); }
public void CanExportFromFactoryObjectIfObjectTypeIsInterface() { using (DefaultListableObjectFactory of = new DefaultListableObjectFactory()) { MockRepository mocks = new MockRepository(); IFactoryObject simpleCounterFactory = (IFactoryObject) mocks.DynamicMock(typeof (IFactoryObject)); Expect.Call(simpleCounterFactory.ObjectType).Return(typeof (ISimpleCounter)); Expect.Call(simpleCounterFactory.IsSingleton).Return(true); Expect.Call(simpleCounterFactory.GetObject()).Return(new SimpleCounter()); mocks.ReplayAll(); of.RegisterSingleton("simpleCounter", simpleCounterFactory); SaoExporter saoExporter = new SaoExporter(); saoExporter.ObjectFactory = of; saoExporter.TargetName = "simpleCounter"; saoExporter.ServiceName = "RemotedSaoCallCounter"; saoExporter.AfterPropertiesSet(); of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()! AssertExportedService(saoExporter.ServiceName, 2); mocks.VerifyAll(); } }
public void BailsWhenNotConfigured() { SaoExporter exp = new SaoExporter(); Assert.Throws <ArgumentException>(() => exp.AfterPropertiesSet()); }
public void BailsWhenNotConfigured() { SaoExporter exp = new SaoExporter(); Assert.Throws<ArgumentException>(() => exp.AfterPropertiesSet()); }