Exemple #1
0
        public void CallServiceAsync_Instance_Action_By_KeyProperty_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.InstanceActionByKeyProperty("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/InstanceActionByKeyProperty"));
            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["entityKey"], Is.EqualTo("abc123"));
            Assert.That(resource["arg"], Is.EqualTo("hello"));
        }
Exemple #2
0
        public void CallService_Instance_Action_By_KeyProperty_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.InstanceActionByKeyProperty("hello"));

            Assert.That(parms, Is.Not.Null);
            Assert.That(parms.Method, Is.EqualTo(HttpMethod.Post));
            Assert.That(parms.Path, Is.EqualTo("dummy/$service/InstanceActionByKeyProperty"));
            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["entityKey"], Is.EqualTo("abc123"));
            Assert.That(resource["arg"], Is.EqualTo("hello"));
        }