/// <summary> /// Returns a proxy to a custom service object. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="host"></param> /// <returns></returns> /// <remarks> /// If the remote service does not serve the requested type of service yet, the /// function registers it before creating a proxy. /// </remarks> public static T CreateObject <T>(string host) where T : IRemoteService { // Get the uri to the requested service from the remote server var sc = RemoteServiceHelper.GetControlObject(GetFullyQualifiedDnsName(host)); var uri = sc.GetServiceEndpointUri(typeof(T).AssemblyQualifiedName); return(CreateChannel <T>(CreateNetTcpBinding(), CreateEndpointAddress(uri))); }
public void CallHelloTest() { using (RemoteServiceTester.Instance.GetToken()) { RemoteServiceTester.Instance.EnsureRunning(); var sc = RemoteServiceHelper.GetControlObject(Jhu.Graywulf.Test.Constants.Localhost); Assert.AreEqual(typeof(Program).Assembly.FullName, sc.Hello()); } }
public void RemoteExecuteTest() { using (RemoteServiceTester.Instance.GetToken()) { RemoteServiceTester.Instance.EnsureRunning(); var c = RemoteServiceHelper.CreateObject <ICancelableDelay>(Jhu.Graywulf.Test.Constants.Localhost); c.Execute(); Assert.IsFalse(c.IsCanceled); } }
public void SessionTest() { using (RemoteServiceTester.Instance.GetToken()) { RemoteServiceTester.Instance.EnsureRunning(); var c1 = RemoteServiceHelper.CreateObject <ICancelableDelay>(Jhu.Graywulf.Test.Constants.Localhost); var c2 = RemoteServiceHelper.CreateObject <ICancelableDelay>(Jhu.Graywulf.Test.Constants.Localhost); c2.Period = 2; c1.Period = 1; Assert.AreEqual(1, c1.Period); Assert.AreEqual(2, c2.Period); } }
public void QueryRegisteredServicesTest() { using (RemoteServiceTester.Instance.GetExclusiveToken()) { // Make sure it's restarted RemoteServiceTester.Instance.EnsureRunning(); RemoteServiceTester.Instance.Stop(); RemoteServiceTester.Instance.EnsureRunning(); var delay = RemoteServiceHelper.CreateObject <ICancelableDelay>(Jhu.Graywulf.Test.Constants.Localhost); var sc = RemoteServiceHelper.GetControlObject(Jhu.Graywulf.Test.Constants.Localhost); var ss = sc.QueryRegisteredServices(); Assert.AreEqual(1, ss.Length); } }
public void GetServiceEndpointUriTest() { using (RemoteServiceTester.Instance.GetToken()) { RemoteServiceTester.Instance.EnsureRunning(); var sc = RemoteServiceHelper.GetControlObject(Jhu.Graywulf.Test.Constants.Localhost); Assert.AreEqual(typeof(Program).Assembly.FullName, sc.Hello()); var uri = sc.GetServiceEndpointUri(typeof(ICancelableDelay).AssemblyQualifiedName); Assert.AreEqual( new Uri(String.Format( "net.tcp://{0}:{1}/{2}", RemoteServiceHelper.GetFullyQualifiedDnsName(Jhu.Graywulf.Test.Constants.Localhost), AppSettings.TcpPort, typeof(CancelableDelay).FullName)), uri); } }
public void CancelRemoteExecuteTest() { using (RemoteServiceTester.Instance.GetToken()) { RemoteServiceTester.Instance.EnsureRunning(); var c = RemoteServiceHelper.CreateObject <ICancelableDelay>(Jhu.Graywulf.Test.Constants.Localhost); c.Period = 10000; var start = DateTime.Now; c.BeginExecute(); System.Threading.Thread.Sleep(1000); c.Cancel(); c.EndExecute(); Assert.IsTrue((DateTime.Now - start).TotalMilliseconds < 5000); Assert.IsTrue(c.IsCanceled); } }
public void CallWhoAreYouTest() { using (RemoteServiceTester.Instance.GetToken()) { RemoteServiceTester.Instance.EnsureRunning(); var sc = RemoteServiceHelper.GetControlObject(Jhu.Graywulf.Test.Constants.Localhost); string name, authtype; bool isauth; sc.WhoAreYou(out name, out isauth, out authtype); // get current identity var id = WindowsIdentity.GetCurrent(); Assert.AreEqual(id.Name, name); Assert.AreEqual(id.IsAuthenticated, isauth); Assert.AreEqual(id.AuthenticationType, authtype); } }
protected void EnsureRoleAccess() { RemoteServiceHelper.EnsureRoleAccess(); }