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 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); }