public void CallServiceAsync_Instance_Action_By_ObjectProperty_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(); clientMock.Object.CallServiceAsync(() => obj.InstanceActionByObjectProperty("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/$service/InstanceActionByObjectProperty")); 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["entity"], Is.EqualTo(obj)); Assert.That(resource["arg"], Is.EqualTo("hello")); }
public void CallService_Instance_Action_By_ObjectProperty_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(); clientMock.Object.CallService(() => obj.InstanceActionByObjectProperty("hello")); Assert.That(parms, Is.Not.Null); Assert.That(parms.Method, Is.EqualTo(HttpMethod.Post)); Assert.That(parms.Path, Is.EqualTo("dummy/$service/InstanceActionByObjectProperty")); 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["entity"], Is.EqualTo(obj)); Assert.That(resource["arg"], Is.EqualTo("hello")); }