private void AssertExportedService(string serviceName, int expectedCount) { ISimpleCounter client = (ISimpleCounter)Activator.GetObject(typeof(ISimpleCounter), "tcp://localhost:8005/" + serviceName); client.Count(); client.Count(); Assert.AreEqual(expectedCount, client.Counter); }
public void GetSaoWithSingletonModeAndAop() { IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/saoSingleton-aop.xml"); ContextRegistry.RegisterContext(ctx); //object saoFactory = ctx.GetObject("&remoteCounter"); //Assert.IsNotNull(saoFactory); object obj = ctx.GetObject("remoteCounter"); Assert.IsNotNull(obj, "Object is null even though a object has been exported."); Assert.IsTrue(AopUtils.IsAopProxy(obj)); Assert.IsTrue((obj is ISimpleCounter), "Object should implement 'ISimpleCounter' interface."); MethodCounter aopCounter = ctx.GetObject("countingBeforeAdvice") as MethodCounter; Assert.IsNotNull(aopCounter); int aopCount = aopCounter.GetCalls("Count"); Assert.AreEqual(0, aopCount); ISimpleCounter sc = (ISimpleCounter)obj; Assert.AreEqual(1, sc.Counter, "Remote object hasn't been activated by the server."); sc.Count(); Assert.AreEqual(2, sc.Counter, "Remote object doesn't work in a 'Singleton' mode."); Assert.AreEqual(1, aopCounter.GetCalls("Count")); }
public void When_RequestingCounterToCount_ItActuallyCounts() { var counter = 100; for (var i = 0; i < counter; i++) { Subject.Count(null); } Assert.AreEqual(counter, Subject.Counter); }
public void GetSimpleObject() { IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/cao.xml"); ContextRegistry.RegisterContext(ctx); object obj = ctx.GetObject("remoteCaoCounter1"); Assert.IsNotNull(obj, "Object is null even though a object has been registered."); Assert.IsTrue((obj is ISimpleCounter), "Object should implement 'ISimpleCounter' interface."); ISimpleCounter sc = (ISimpleCounter)obj; Assert.AreEqual(7, sc.Counter, "Remote object hasn't been activated by the client."); sc.Count(); Assert.AreEqual(8, sc.Counter); }
public void GetSaoWithSingletonMode() { IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Services.Tests/Spring.Data.Spring.Remoting/saoSingleton.xml"); ContextRegistry.RegisterContext(ctx); object obj = ctx.GetObject("remoteSaoSingletonCounter"); Assert.IsNotNull(obj, "Object is null even though a object has been exported."); Assert.IsTrue((obj is ISimpleCounter), "Object should implement 'ISimpleCounter' interface."); ISimpleCounter sc = (ISimpleCounter)obj; Assert.AreEqual(1, sc.Counter, "Remote object hasn't been activated by the server."); sc.Count(); Assert.AreEqual(2, sc.Counter, "Remote object doesn't work in a 'Singleton' mode."); }
public void Count() { service.Count(); }