public void CreateRemoteObject() { RemoteObjectFactory factory = new RemoteObjectFactory(); factory.Target = new SimpleCounter(); factory.AfterPropertiesSet(); object obj = factory.GetObject(); Assert.IsTrue((obj is MarshalByRefObject), "Object should derive from MarshalByRefObject."); }
public void ReturnsInterfaceImplementation() { RemoteObjectFactory factory = new RemoteObjectFactory(); factory.Target = new SimpleCounter(); factory.AfterPropertiesSet(); object obj = factory.GetObject(); Assert.IsTrue((obj is ISimpleCounter), "Object should implement an interface."); }
/// <summary> /// Create a new instance of the RemoteFactory. /// </summary> public CaoRemoteFactory(ILifetime lifetime, string targetName, string[] interfaces, AbstractObjectFactory objectFactory) { this.targetName = targetName; this.objectFactory = objectFactory; this.remoteObjectFactory = new RemoteObjectFactory(); this.remoteObjectFactory.BaseType = typeof(BaseCao); this.remoteObjectFactory.Interfaces = interfaces; this.remoteObjectFactory.Infinite = lifetime.Infinite; this.remoteObjectFactory.InitialLeaseTime = lifetime.InitialLeaseTime; this.remoteObjectFactory.RenewOnCallTime = lifetime.RenewOnCallTime; this.remoteObjectFactory.SponsorshipTimeout = lifetime.SponsorshipTimeout; }
public void CreateRemoteObjectWithLeaseInfo() { RemoteObjectFactory factory = new RemoteObjectFactory(); factory.Target = new SimpleCounter(); factory.Infinite = false; factory.InitialLeaseTime = TimeSpan.FromMilliseconds(10000); factory.RenewOnCallTime = TimeSpan.FromMilliseconds(1000); factory.SponsorshipTimeout = TimeSpan.FromMilliseconds(100); MarshalByRefObject remoteObject = (MarshalByRefObject) factory.GetObject(); ILease lease = (ILease) remoteObject.InitializeLifetimeService(); Assert.AreEqual(TimeSpan.FromMilliseconds(10000), lease.InitialLeaseTime, "InitialLeaseTime"); Assert.AreEqual(TimeSpan.FromMilliseconds(1000), lease.RenewOnCallTime, "RenewOnCallTime"); Assert.AreEqual(TimeSpan.FromMilliseconds(100), lease.SponsorshipTimeout, "SponsorshipTimeout"); }
public void CreateRemoteObjectWithLeaseInfo() { RemoteObjectFactory factory = new RemoteObjectFactory(); factory.Target = new SimpleCounter(); factory.Infinite = false; factory.InitialLeaseTime = TimeSpan.FromMilliseconds(10000); factory.RenewOnCallTime = TimeSpan.FromMilliseconds(1000); factory.SponsorshipTimeout = TimeSpan.FromMilliseconds(100); MarshalByRefObject remoteObject = (MarshalByRefObject)factory.GetObject(); ILease lease = (ILease)remoteObject.InitializeLifetimeService(); Assert.AreEqual(TimeSpan.FromMilliseconds(10000), lease.InitialLeaseTime, "InitialLeaseTime"); Assert.AreEqual(TimeSpan.FromMilliseconds(1000), lease.RenewOnCallTime, "RenewOnCallTime"); Assert.AreEqual(TimeSpan.FromMilliseconds(100), lease.SponsorshipTimeout, "SponsorshipTimeout"); }
public void BailsWhenNotConfigured() { RemoteObjectFactory factory = new RemoteObjectFactory(); factory.AfterPropertiesSet(); }
public void BailsWhenNotConfigured() { RemoteObjectFactory factory = new RemoteObjectFactory(); Assert.Throws <ArgumentException>(() => factory.AfterPropertiesSet(), "The Target property is required."); }
public void BailsWhenNotConfigured() { RemoteObjectFactory factory = new RemoteObjectFactory(); Assert.Throws<ArgumentException>(() => factory.AfterPropertiesSet(), "The Target property is required."); }