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

            ExceptionAssert.ExpectAggregateException(() => collection.AddAsync(null).Wait(), typeof(ArgumentNullException));
        }
Exemplo n.º 2
0
        public void DdpCollection_AddAsync_CallsServerMethod()
        {
            var remoteMethodCall = new Mock<IDdpRemoteMethodCall>();
            var collection = new DdpCollection<TestDdpObject>(remoteMethodCall.Object, "TestCollection");

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

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

            collection.AddAsync(testObject).Wait();

            remoteMethodCall.Verify(
                x =>
                    x.Call(It.Is<string>(s => s.Equals(@"/TestCollection/insert")),
                        It.Is<object[]>(c => c.Length == 1 && c.First() == testObject)));
        }