Exemplo n.º 1
0
        public void DdpCollection_UpdateAsync_CallsServerMethod()
        {
            var remoteMethodCall = new Mock<IDdpRemoteMethodCall>();
            var collection = new DdpCollection<TestDdpObject>(remoteMethodCall.Object, "TestCollection");

            var testObject = new TestDdpObject() { Id = "11", integerField = 10, StringProperty = "FooBar" };

            remoteMethodCall.Setup(x => x.Call<int>(It.IsAny<string>(), It.IsAny<object[]>()))
                .Returns(Task.FromResult(1));

            collection.UpdateAsync(testObject.Id, testObject);

            remoteMethodCall.Verify(
                x =>
                    x.Call<int>(It.Is<string>(s => s.Equals(@"/TestCollection/update")),
                        It.Is<object[]>(
                            c =>
                                c.Length == 2 && ((IdParameter) c[0]).Id == "11" && ((Set) c[1]).ObjectToSet == testObject)));
        }
Exemplo n.º 2
0
        public void DdpCollection_UpdateAsync_NullItem()
        {
            var remoteMethodCall = new Mock<IDdpRemoteMethodCall>();
            var collection = new DdpCollection<TestDdpObject>(remoteMethodCall.Object, "TestCollection");

            PCLTesting.ExceptionAssert.Throws<ArgumentNullException>(() => collection.UpdateAsync("ID", null));
        }
Exemplo n.º 3
0
        public void DdpCollection_UpdateAsync_NullID()
        {
            var remoteMethodCall = new Mock<IDdpRemoteMethodCall>();
            var collection = new DdpCollection<TestDdpObject>(remoteMethodCall.Object, "TestCollection");

            var testObject = new TestDdpObject() { Id = "11", integerField = 10, StringProperty = "FooBar" };

            PCLTesting.ExceptionAssert.Throws<ArgumentNullException>(() => collection.UpdateAsync(string.Empty, testObject));
        }