public void CanExportAopProxyToLibrary() { // NOTE: the method interceptor will return the number of method calls intercepted FileInfo assemblyFile = new FileInfo("ServiceComponentExporterTests.TestServicedComponents.dll"); XmlApplicationContext appCtx = new XmlApplicationContext("ServiceComponentExporterTests.TestServicedComponents.Services.xml"); EnterpriseServicesExporter exporter = new EnterpriseServicesExporter(); exporter.ActivationMode = ActivationOption.Library; Type serviceType = ExportObject(exporter, assemblyFile, appCtx, "objectTest"); try { // ServiceComponent will obtain its target from root context // ContextRegistry.RegisterContext(appCtx); IComparable testObject; testObject = (IComparable)Activator.CreateInstance(serviceType); Assert.AreEqual(1, testObject.CompareTo(null)); testObject = (IComparable)Activator.CreateInstance(serviceType); Assert.AreEqual(2, testObject.CompareTo(null)); } finally { exporter.UnregisterServicedComponents(assemblyFile); ContextRegistry.Clear(); } }
public void CanExportAopProxyToServer() { FileInfo assemblyFile = new FileInfo("ServiceComponentExporterTests.TestServicedComponents.exe"); XmlApplicationContext appCtx = new XmlApplicationContext("ServiceComponentExporterTests.TestServicedComponents.Services.xml"); EnterpriseServicesExporter exporter = new EnterpriseServicesExporter(); exporter.ActivationMode = ActivationOption.Server; Type serviceType = ExportObject(exporter, assemblyFile, appCtx, "objectTest"); try { // ServiceComponent will obtain its target from root context IComparable testObject; testObject = (IComparable)Activator.CreateInstance(serviceType); Assert.AreEqual(1, testObject.CompareTo(null)); testObject = (IComparable)Activator.CreateInstance(serviceType); Assert.AreEqual(2, testObject.CompareTo(null)); } finally { exporter.UnregisterServicedComponents(assemblyFile); } }