Example #1
0
        public void SupportedQuery()
        {
            TDST_DomainService domainService = this.CreateDomainService(DomainOperationType.Query);

            IQueryable       query = new TDST_MockEntity[0].AsQueryable().Where(e => e.RowKey != "1");
            QueryDescription qd    = new QueryDescription(domainService.MockDescription.GetQueryMethod("GetEntities"), new object[0], false, query);

            IEnumerable <ValidationResult> validationErrors;
            int totalCount;

            IEnumerable entities = domainService.Query(qd, out validationErrors, out totalCount);

            Assert.IsNotNull(entities,
                             "Query result should not be null.");
            Assert.AreEqual(4, entities.Cast <TDST_MockEntity>().Count(),
                            "There should be 4 entities in the filtered collection.");
            Assert.AreEqual("5", entities.Cast <TDST_MockEntity>().Last().RowKey,
                            "The RowKey of the final entity should be 5.");
        }
Example #2
0
        public void UnsupportedQuery()
        {
            TDST_DomainService domainService = this.CreateDomainService(DomainOperationType.Query);

            IQueryable       query = new TDST_MockEntity[0].AsQueryable().OrderByDescending(e => e.RowKey);
            QueryDescription qd    = new QueryDescription(domainService.MockDescription.GetQueryMethod("GetEntities"), new object[0], false, query);

            IEnumerable <ValidationResult> validationErrors;
            int totalCount;

            IEnumerable entities = domainService.Query(qd, out validationErrors, out totalCount);

            Assert.IsNotNull(entities,
                             "Query result should not be null.");
            Assert.AreEqual(5, entities.Cast <TDST_MockEntity>().Count(),
                            "There should be 5 entities in the filtered collection.");
            Assert.AreEqual("1", entities.Cast <TDST_MockEntity>().Last().RowKey,
                            "The RowKey of the final entity should be 1.");
            // Not an official contract, but the serializer requires entities to be pre-enumerated
            Assert.IsInstanceOfType(entities, typeof(TDST_MockEntity[]),
                                    "Entities should be a TDST_MockEntity[].");
        }