public void CallServiceAsync_Instance_Action_By_Selector_Test() { var clientMock = new Mock <ISDataClient>(); SDataParameters parms = null; var taskSource = new TaskCompletionSource <ISDataResults>(); taskSource.SetResult(null); clientMock.Setup(x => x.ExecuteAsync(It.IsAny <SDataParameters>(), CancellationToken.None)) .Callback((SDataParameters p, CancellationToken c) => parms = p) .Returns(taskSource.Task); var obj = new CallService_Object { Key = "abc123" }; clientMock.Object.CallServiceAsync(() => obj.InstanceActionBySelector("hello"), null, CancellationToken.None).Wait(CancellationToken.None); Assert.That(parms, Is.Not.Null); Assert.That(parms.Method, Is.EqualTo(HttpMethod.Post)); Assert.That(parms.Path, Is.EqualTo("dummy('abc123')/$service/InstanceActionBySelector")); var resource = parms.Content as SDataResource; Assert.That(resource, Is.Not.Null); resource = resource["request"] as SDataResource; Assert.That(resource, Is.Not.Null); Assert.That(resource["arg"], Is.EqualTo("hello")); }
public void CallService_Instance_Action_By_Selector_Test() { var clientMock = new Mock <ISDataClient>(); SDataParameters parms = null; clientMock.Setup(x => x.Execute(It.IsAny <SDataParameters>())) .Callback((SDataParameters p) => parms = p); var obj = new CallService_Object { Key = "abc123" }; clientMock.Object.CallService(() => obj.InstanceActionBySelector("hello")); Assert.That(parms, Is.Not.Null); Assert.That(parms.Method, Is.EqualTo(HttpMethod.Post)); Assert.That(parms.Path, Is.EqualTo("dummy('abc123')/$service/InstanceActionBySelector")); var resource = parms.Content as SDataResource; Assert.That(resource, Is.Not.Null); resource = resource["request"] as SDataResource; Assert.That(resource, Is.Not.Null); Assert.That(resource["arg"], Is.EqualTo("hello")); }