public void Test_GetAllOrdersOverWCF()
 {
     OrderQueryServiceReference.OrderQueryServiceClient query = new OrderProcessing.Tests.OrderQueryServiceReference.OrderQueryServiceClient();
       Common.Util.AssignContextId(query.InnerChannel);
       Order[] results = query.All();
       int count = results.Length;
       Assert.That(count, Is.GreaterThan(0));
 }
        public void TestDeleteOrderAndUndoUsingWCFAsync()
        {
            NotificationHandler handler = new NotificationHandler();
              InstanceContext cntx = new InstanceContext(handler);
              SubscriptionServiceReference.SubscriptionServiceClient proxy = new OrderProcessing.Tests.SubscriptionServiceReference.SubscriptionServiceClient(cntx);
              proxy.Subscribe();

              string contextId = Guid.NewGuid().ToString();
              CommanndServiceReference.CommandServiceClient commandClient = new OrderProcessing.Tests.CommanndServiceReference.CommandServiceClient();
              OrderQueryServiceReference.OrderQueryServiceClient service = new OrderProcessing.Tests.OrderQueryServiceReference.OrderQueryServiceClient();

              //Common.Util.SetContextId(commandClient.InnerChannel, contextId);
              AssignContextId(commandClient.InnerChannel, contextId);
              AssignContextId(service.InnerChannel, contextId);
              //Common.Util.SetContextId(service.InnerChannel, contextId);

              long numOrders = service.Count();
              var allOrders = service.All();
              Order order = allOrders.ElementAt(new Random().Next(0, (int)numOrders - 1));
              RemoveOrderCommand remCommand = new RemoveOrderCommand(order);
              //commandClient.BeginExecuteCommand(remCommand, ar => {}, null);
              commandClient.ExecuteCommand(remCommand);
              commandClient.UndoCommand(remCommand);
              long numOrdersAfter = service.Count();
              Assert.That(numOrdersAfter, Is.EqualTo(numOrders));
        }