Exemple #1
0
        public void CreatingRequestWithReturnValueAndParams()
        {
            MockRequestQueue queue = new MockRequestQueue();

            OfflineMockService proxy = new OfflineMockService(queue);

            MockServiceDataContract obj = new MockServiceDataContract("Jose", 31);

            proxy.DoWithParamsAndReturn(1, obj);


            Request r = queue.GetNextRequest();

            Assert.AreSame(obj, r.CallParameters[1]);
            Assert.AreEqual("MockService", r.Endpoint);
            Assert.AreEqual("DoWithParamsAndReturn", r.MethodName);
            Assert.AreEqual(typeof(MockService), r.OnlineProxyType);
            Assert.AreEqual("OnDoWithParamsAndReturnReturn", r.Behavior.ReturnCallback.TargetMethodName);
            Assert.AreEqual(typeof(OfflineMockServiceCallbacks), r.Behavior.ReturnCallback.TargetType);

            Assert.AreEqual("OnMockServiceException", r.Behavior.ExceptionCallback.TargetMethodName);
            Assert.AreEqual(typeof(OfflineMockServiceCallbacks), r.Behavior.ExceptionCallback.TargetType);

            //these test the default behavior; which should have been set by the recipe when creating the OfflineSvcAgent
            Assert.AreEqual(null, r.Behavior.Expiration);
            Assert.AreEqual(1, r.Behavior.MaxRetries);
            Assert.AreEqual(3, r.Behavior.Stamps);
            Assert.AreEqual("", r.Behavior.Tag);
            Assert.IsNotNull(r.Behavior.MessageId);
        }
        public void DoWithParamsAndReturn(int p, MockServiceDataContract obj)
        {
            OfflineBehavior behavior = GetDefaultOfflineBehavior();

            behavior.ReturnCallback = new CommandCallback(typeof(OfflineMockServiceCallbacks), "OnDoWithParamsAndReturnReturn");

            DoWithParamsAndReturn(p, obj, behavior);
        }
 public int DoWithOutParamsAndReturn(int inNumber, out int outNumber, MockServiceDataContract inObj,
                                     out MockServiceDataContract outObj)
 {
     Invoked   = true;
     outNumber = inNumber;
     outObj    = inObj;
     return(inObj.Age);
 }
        public void DoWithParamsAndReturn(int p, MockServiceDataContract obj, OfflineBehavior behavior)
        {
            Request r = new Request();

            r.MethodName      = "DoWithParamsAndReturn";
            r.Endpoint        = "MockService";
            r.OnlineProxyType = typeof(MockService);
            r.CallParameters  = CallParameters.ToArray(p, obj);

            r.Behavior = behavior;

            requestQueue.Enqueue(r);
        }
Exemple #5
0
        public void CreatingRequestWithReturnValueAndSpecificBehavior()
        {
            MockRequestQueue        queue = new MockRequestQueue();
            OfflineMockService      proxy = new OfflineMockService(queue);
            MockServiceDataContract obj   = new MockServiceDataContract("Jose", 31);

            OfflineBehavior behavior = new OfflineBehavior();

            behavior.MaxRetries     = 7;
            behavior.Stamps         = 5;
            behavior.Tag            = "Test";
            behavior.ReturnCallback =
                new CommandCallback(typeof(OfflineMockServiceCallbacks), "OnDoWithParamsAndReturnAlternativeReturn");
            behavior.ExceptionCallback = new CommandCallback(typeof(OfflineMockServiceCallbacks), "OnMockServiceOtherException");
            DateTime expDate = DateTime.Now + TimeSpan.FromHours(2);

            behavior.Expiration = expDate;
            Guid behId = Guid.NewGuid();

            behavior.MessageId = behId;

            proxy.DoWithParamsAndReturn(1, obj, behavior);

            Request r = queue.GetNextRequest();

            Assert.AreEqual(behId, r.Behavior.MessageId);
            Assert.AreSame(obj, r.CallParameters[1]);
            Assert.AreEqual("MockService", r.Endpoint);
            Assert.AreEqual("DoWithParamsAndReturn", r.MethodName);
            Assert.AreEqual(typeof(MockService), r.OnlineProxyType);

            Assert.AreEqual("OnDoWithParamsAndReturnAlternativeReturn", r.Behavior.ReturnCallback.TargetMethodName);
            Assert.AreEqual(typeof(OfflineMockServiceCallbacks), r.Behavior.ReturnCallback.TargetType);
            Assert.AreEqual("OnMockServiceOtherException", r.Behavior.ExceptionCallback.TargetMethodName);
            Assert.AreEqual(typeof(OfflineMockServiceCallbacks), r.Behavior.ExceptionCallback.TargetType);

            //these test the default behavior; which should have been set by the recipe when creating the OfflineSvcAgent
            Assert.AreEqual(expDate, r.Behavior.Expiration);
            Assert.AreEqual(7, r.Behavior.MaxRetries);
            Assert.AreEqual(5, r.Behavior.Stamps);
            Assert.AreEqual("Test", r.Behavior.Tag);
        }
 public int DoWithParamsAndReturn(int number, MockServiceDataContract obj)
 {
     Invoked = true;
     return(obj.Age);
 }