public void TestMockClientReturnsNull()
        {
            NullReturningMockDomainClient dc = new NullReturningMockDomainClient();

            AsyncCallback ignored = delegate { };

            InvokeArgs invokeArgs          = new InvokeArgs("M", typeof(void), null, true /*hasSideEffects*/);
            DomainClientAsyncResult result = (DomainClientAsyncResult)dc.BeginInvoke(invokeArgs, ignored, null);

            EnqueueConditional(() => result != null);

            EnqueueCallback(delegate
            {
                Assert.IsNull(result.InnerAsyncResult);

                ExceptionHelper.ExpectArgumentNullException(
                    () => dc.EndInvoke(result.InnerAsyncResult),
                    "asyncResult");

                result = null;
                result = (DomainClientAsyncResult)dc.BeginQuery(new EntityQuery <Entity>(dc, "GetIgnored", null, true, false), ignored, null);
            });

            EnqueueConditional(() => result != null);

            EnqueueCallback(delegate
            {
                Assert.IsNull(result.InnerAsyncResult);

                ExceptionHelper.ExpectArgumentNullException(
                    () => dc.EndQuery(result.InnerAsyncResult),
                    "asyncResult");

                List <Entity> list = new List <Entity>();
                list.Add(new Product());
                ReadOnlyCollection <Entity> simpleCollection = new ReadOnlyCollection <Entity>(list);
                ReadOnlyCollection <Entity> emptyCollection  = new ReadOnlyCollection <Entity>(new List <Entity>());
                EntityChangeSet emptyChangeSet = new EntityChangeSet(simpleCollection, emptyCollection, emptyCollection);
                result = null;
                result = (DomainClientAsyncResult)dc.BeginSubmit(emptyChangeSet, ignored, null);
            });

            EnqueueConditional(() => result != null);

            EnqueueCallback(delegate
            {
                Assert.IsNull(result.InnerAsyncResult);

                ExceptionHelper.ExpectArgumentNullException(
                    () => dc.EndSubmit(result.InnerAsyncResult),
                    "asyncResult");
            });

            EnqueueTestComplete();
        }
        public void TestMockClientReturnsNull()
        {
            NullReturningMockDomainClient dc = new NullReturningMockDomainClient();

            AsyncCallback ignored = delegate { };

            InvokeArgs invokeArgs = new InvokeArgs("M", typeof(void), null, true /*hasSideEffects*/);
            DomainClientAsyncResult result = (DomainClientAsyncResult)dc.BeginInvoke(invokeArgs, ignored, null);

            EnqueueConditional(() => result != null);

            EnqueueCallback(delegate
            {
                Assert.IsNull(result.InnerAsyncResult);

                ExceptionHelper.ExpectArgumentNullException(
                () => dc.EndInvoke(result.InnerAsyncResult),
                "asyncResult");

                result = null;
                result = (DomainClientAsyncResult)dc.BeginQuery(new EntityQuery<Entity>(dc, "GetIgnored", null, true, false), ignored, null);
            });

            EnqueueConditional(() => result != null);

            EnqueueCallback(delegate
            {
                Assert.IsNull(result.InnerAsyncResult);

                ExceptionHelper.ExpectArgumentNullException(
                    () => dc.EndQuery(result.InnerAsyncResult),
                    "asyncResult");

                List<Entity> list = new List<Entity>();
                list.Add(new Product());
                ReadOnlyCollection<Entity> simpleCollection = new ReadOnlyCollection<Entity>(list);
                ReadOnlyCollection<Entity> emptyCollection = new ReadOnlyCollection<Entity>(new List<Entity>());
                EntityChangeSet emptyChangeSet = new EntityChangeSet(simpleCollection, emptyCollection, emptyCollection);
                result = null;
                result = (DomainClientAsyncResult)dc.BeginSubmit(emptyChangeSet, ignored, null);
            });

            EnqueueConditional(() => result != null);

            EnqueueCallback(delegate
            {
                Assert.IsNull(result.InnerAsyncResult);

                ExceptionHelper.ExpectArgumentNullException(
                    () => dc.EndSubmit(result.InnerAsyncResult),
                    "asyncResult");
            });

            EnqueueTestComplete();
        }