Beispiel #1
0
        public void CanSpecifyBehaviorsForTheRequest()
        {
            MockRequestQueue queue = new MockRequestQueue();

            OfflineMockService proxy = new OfflineMockService(queue);

            OfflineBehavior beh = new OfflineBehavior();

            beh.Tag            = "tag";
            beh.Stamps         = 3;
            beh.MaxRetries     = 5;
            beh.ReturnCallback = new CommandCallback(typeof(OfflineMockServiceCallbacks), "SomeOtherMethod");
            beh.Expiration     = DateTime.MinValue;

            proxy.DoWithNoParams(beh);

            Request r = queue.GetNextRequest();

            Assert.AreEqual(beh, r.Behavior);
            Assert.AreEqual(DateTime.MinValue, r.Behavior.Expiration);
            Assert.AreEqual(5, r.Behavior.MaxRetries);
            Assert.AreEqual("SomeOtherMethod", r.Behavior.ReturnCallback.TargetMethodName);
            Assert.AreEqual(typeof(OfflineMockServiceCallbacks), r.Behavior.ReturnCallback.TargetType);
            Assert.AreEqual(3, r.Behavior.Stamps);
            Assert.AreEqual("tag", r.Behavior.Tag);
        }
Beispiel #2
0
        public void CreateOnlineProxyAndInvokeResultsInRequestInQueue()
        {
            MockRequestQueue queue = new MockRequestQueue();

            OfflineMockService proxy = new OfflineMockService(queue);

            proxy.DoWithNoParams();

            Request r = queue.GetNextRequest();

            Assert.AreEqual("DoWithNoParams", r.MethodName);
            Assert.AreEqual("MockService", r.Endpoint);
            Assert.AreSame(typeof(MockService), r.OnlineProxyType);

            OfflineBehavior defaultBehavior = new OfflineBehavior();

            defaultBehavior.Expiration        = null;
            defaultBehavior.MaxRetries        = 1;
            defaultBehavior.ReturnCallback    = new CommandCallback(typeof(OfflineMockServiceCallbacks), "DoWithNoParamsCallback");
            defaultBehavior.ExceptionCallback = new CommandCallback(typeof(OfflineMockServiceCallbacks), "OfflineCallFailed");
            defaultBehavior.Stamps            = 3;
            defaultBehavior.Tag = "";

            Assert.AreEqual(defaultBehavior.Expiration, r.Behavior.Expiration);
            Assert.AreEqual(defaultBehavior.MaxRetries, r.Behavior.MaxRetries);
            Assert.AreEqual(defaultBehavior.ReturnCallback.TargetMethodName, r.Behavior.ReturnCallback.TargetMethodName);
            Assert.AreEqual(defaultBehavior.ReturnCallback.TargetType, r.Behavior.ReturnCallback.TargetType);
            Assert.AreEqual(defaultBehavior.Stamps, r.Behavior.Stamps);
            Assert.AreEqual(defaultBehavior.Tag, r.Behavior.Tag);
        }