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 AddNullReferenceThrows()
        {
            // Add null reference, exception should be thrown
            ExceptionHelper.ExpectArgumentNullException(
                () => this.CustomerDomainService.AddReference(typeof(MockCustomer), null),
                "domainContext");

            // Add null reference, exception should be thrown
            ExceptionHelper.ExpectArgumentNullException(
                () => this.CustomerDomainService.AddReference(null, null),
                "entityType");
        }
Ejemplo n.º 3
0
        public void EntityConflict_ArgumentNullExceptions()
        {
            MockEntity           entity        = new MockEntity();
            IEnumerable <string> propertyNames = new[] { "Property1" };

            ExceptionHelper.ExpectArgumentNullException(
                () => new EntityConflict(entity, null, propertyNames, false),
                "storeEntity");

            ExceptionHelper.ExpectArgumentNullException(
                () => new EntityConflict(null, entity, propertyNames, false),
                "currentEntity");

            ExceptionHelper.ExpectArgumentNullException(
                () => new EntityConflict(entity, entity, null, false),
                "propertyNames");
        }
Ejemplo n.º 4
0
        public void PoxBufferedMessage_BufferedCopy_Negative()
        {
            // write message throws argument null
            // All props throw after close, create message, write message throw after close

            using (Message message = this.GetMessage())
            {
                MessageBuffer buffer = message.CreateBufferedCopy(0);
                // WriteMessage throws ArgumentNullException.
                ExceptionHelper.ExpectArgumentNullException(() =>
                {
                    buffer.WriteMessage(null);
                }, "stream");

                // All members throw ObjectDisposedException after Close.
                buffer.Close();
                ExceptionHelper.ExpectException <ObjectDisposedException>(() =>
                {
                    int bufferSize = buffer.BufferSize;
                }, ObjectDisposedText);

                ExceptionHelper.ExpectException <ObjectDisposedException>(() =>
                {
                    string contentType = buffer.MessageContentType;
                }, ObjectDisposedText);

                ExceptionHelper.ExpectException <ObjectDisposedException>(() =>
                {
                    buffer.CreateMessage();
                }, ObjectDisposedText);

                ExceptionHelper.ExpectException <ObjectDisposedException>(() =>
                {
                    using (MemoryStream stream = new MemoryStream())
                    {
                        buffer.WriteMessage(stream);
                    }
                }, ObjectDisposedText);
            }
        }
Ejemplo n.º 5
0
        public void ParameterChecking()
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "a", 1 },
                { "b", 2 }
            };
            EntityQuery <City> baseQuery = new EntityQuery <City>(_testClient, "GetCities", null, false, true);

            ExceptionHelper.ExpectArgumentNullException(delegate
            {
                EntityQuery <City> citiesQuery = new EntityQuery <City>(_testClient, null, parameters, false, true);
            }, "queryName");

            ExceptionHelper.ExpectArgumentNullException(delegate
            {
                EntityQuery <City> citiesQuery = new EntityQuery <City>(_testClient, string.Empty, parameters, false, true);
            }, "queryName");

            ExceptionHelper.ExpectArgumentNullException(delegate
            {
                EntityQuery <City> citiesQuery = new EntityQuery <City>(null, "GetCities", parameters, false, true);
            }, "domainClient");

            ExceptionHelper.ExpectArgumentNullException(delegate
            {
                EntityQuery <City> citiesQuery = new EntityQuery <City>(null, new City[0].AsQueryable().Where(p => p.StateName == "Toledo"));
            }, "baseQuery");

            ExceptionHelper.ExpectArgumentNullException(delegate
            {
                EntityQuery <City> citiesQuery = new EntityQuery <City>(baseQuery, null);
            }, "query");

            ExceptionHelper.ExpectArgumentNullException(delegate
            {
                EntityQuery <City> citiesQuery = new EntityQuery <City>(baseQuery, null);
            }, "query");
        }