public void TestInvalidProviderName()
        {
            // first test an invalid name
            TestDataContext ctxt = new TestDataContext(new Uri(TestURIs.RootURI, "TestDomainServices-DNE.svc"));
            LoadOperation   lo   = ctxt.Load(ctxt.CreateQuery <Product>("NonExistentMethod", null), false);

            EnqueueConditional(delegate {
                return(lo.IsComplete);
            });
            EnqueueCallback(delegate {
                Assert.IsNotNull(lo.Error);
                Assert.IsTrue(lo.Error.Message.Contains("Load operation failed"));
            });

            // now test an empty name (just the service path is specified w/o a DomainService name)
            EnqueueCallback(delegate {
                ctxt = new TestDataContext(TestURIs.RootURI);
                lo   = ctxt.Load(ctxt.CreateQuery <Product>("NonExistentMethod", null), false);
            });
            EnqueueConditional(delegate {
                return(lo.IsComplete);
            });
            EnqueueCallback(delegate {
                Assert.IsNotNull(lo.Error);
                Assert.IsTrue(lo.Error.Message.Contains("Load operation failed"));
            });

            EnqueueTestComplete();
        }
        public void TestInvalidMethodName()
        {
            TestDataContext ctxt = new TestDataContext(TestURIs.LTS_Catalog);

            ExceptionHelper.ExpectException <MissingMethodException>(delegate
            {
                ctxt.Load(ctxt.CreateQuery <Product>("DNE", null), false);
            }, String.Format(Resource.WebDomainClient_OperationDoesNotExist, "DNE"));
        }
Пример #3
0
        public void TestNonDomainService()
        {
            TestDataContext ctxt = new TestDataContext(new Uri(TestURIs.RootURI, "TestDomainServices-NonDomainService.svc"));
            LoadOperation   lo   = ctxt.Load(ctxt.CreateQuery <Product>("GetProducts", null), false);

            this.EnqueueCompletion(() => lo);
            EnqueueCallback(delegate
            {
                Assert.IsNotNull(lo.Error);
                // TODO: Assert proper error message... Note: WCF error messages differ between desktop and Silverlight.
                //Assert.IsTrue(lo.Error.InnerException.Message.StartsWith("There was no endpoint listening"));
                //Assert.AreEqual(OperationErrorStatus.NotFound, ex.Status);
                //Assert.AreEqual(Resource.DomainClient_ResourceNotFound, ex.Message);
            });
            EnqueueTestComplete();
        }
Пример #4
0
        public void TestL2SProviderConstructorThrows()
        {
            // Test for a provider that derives from LinqToSqlDomainService, since LinqToSqlDomainService is instantiated differently
            TestDataContext ctxt = new TestDataContext(new Uri(TestURIs.RootURI, "TestDomainServices-ThrowingDomainServiceL2S.svc"));
            LoadOperation   lo   = ctxt.Load(ctxt.CreateQuery <Product>("GetProducts", null), false);

            this.EnqueueCompletion(() => lo);
            EnqueueCallback(delegate
            {
                DomainOperationException ex = (DomainOperationException)lo.Error;
                Assert.IsNotNull(ex);
                Assert.AreEqual(OperationErrorStatus.NotSupported, ex.Status);
                Assert.AreEqual(string.Format(Resource.DomainContext_LoadOperationFailed, "GetProducts", "Couldn't construct this type."), ex.Message);
            });

            EnqueueTestComplete();
        }
        public void TestProviderConstructorThrows()
        {
            // first test for a provider that derives from DomainService
            TestDataContext ctxt = new TestDataContext(new Uri(TestURIs.RootURI, "TestDomainServices-ThrowingDomainService.svc"));
            LoadOperation   lo   = ctxt.Load(ctxt.CreateQuery <Product>("GetProducts", null), false);

            EnqueueConditional(delegate
            {
                return(lo.IsComplete);
            });
            EnqueueCallback(delegate
            {
                DomainOperationException ex = (DomainOperationException)lo.Error;
                Assert.IsNotNull(ex);
                Assert.AreEqual(OperationErrorStatus.NotSupported, ex.Status);
                Assert.AreEqual(string.Format(Resource.DomainContext_LoadOperationFailed, "GetProducts", "Can't construct this type."), ex.Message);
            });

            EnqueueTestComplete();
        }