public void MethodOne_Unhandled() { OneClient svc = new OneClient(); svc.ActivityId = Guid.NewGuid(); svc.AccessToken = "my.jwt.token"; try { svc.MethodOne(new Zn.Sample.OneSvc.MethodOneRequest() { Value = 15 }); Assert.Fail("Expected exception."); } catch (ServiceFaultException ex) { // Zinc.WebServices.ZincException Assert.AreEqual("ZnSample.Zinc", ex.Actor); Assert.AreEqual(4006, ex.Code); // System.Exception Assert.IsTrue(ex.InnerException != null, "Expected inner exception."); Assert.IsTrue(ex.InnerException is ActorException, "Inner exception must be ActorException."); ActorException iex = (ActorException)ex.InnerException; Assert.AreEqual("ZnSample", iex.Actor); Assert.AreEqual(991, iex.Code); } catch (Exception ex) { Assert.Fail("Expected named exception, instead got: " + ex.GetType().FullName); } }
public void Sync() { OneClient svc = new OneClient(); svc.ActivityId = Guid.NewGuid(); svc.AccessToken = "my.jwt.token"; try { var response = svc.MethodOne(new Zn.Sample.OneSvc.MethodOneRequest() { Value = 10 }); Assert.Fail("Expected exception."); } catch (ServiceException ex) { Assert.AreEqual("Invoke_NotJson", ex.Message); Assert.AreEqual("ZnClient.Sample", ex.Actor); } catch (Exception ex) { Assert.Fail("Expected named exception, instead got: " + ex.GetType().FullName); } }
public void MethodOne_Ok() { OneClient svc = new OneClient(); svc.ActivityId = Guid.NewGuid(); svc.AccessToken = "my.jwt.token"; var response = svc.MethodOne(new Zn.Sample.OneSvc.MethodOneRequest() { Value = 10 }); Assert.AreEqual(100, response.Value); }
/// <summary /> public static void MainSync(int value, int count) { var svc = new OneClient(); svc.ActivityId = Guid.NewGuid(); Console.WriteLine("URL=" + svc.ServiceUrl); for (int i = 0; i < count; i++) { DateTime start = DateTime.UtcNow; try { var t1 = svc.MethodOne(new OneSvc.MethodOneRequest() { Value = value, }); Console.Write("OK "); } catch (ServiceFaultException) { Console.Write("ER "); } catch (Exception) { Console.Write("EX "); } try { var t2 = svc.MethodOne(new OneSvc.MethodOneRequest() { Value = value + 5, }); Console.Write("OK "); } catch (ServiceFaultException) { Console.Write("ER "); } catch (Exception) { Console.Write("EX "); } try { var t3 = svc.MethodOne(new OneSvc.MethodOneRequest() { Value = value + 3, }); Console.Write("OK "); } catch (ServiceFaultException) { Console.Write("ER "); } catch (Exception) { Console.Write("EX "); } DateTime end = DateTime.UtcNow; TimeSpan ts = end - start; Console.WriteLine("{0} {1:000.000}ms", i, ts.TotalMilliseconds); } }