コード例 #1
0
        public void PartitionKey()
        {
            TDST_DomainService domainService = this.CreateDomainService(DomainOperationType.Metadata);

            Assert.AreEqual(domainService.MockPartitionKey, domainService.MockEntityContext.PartitionKey,
                            "PartitionKeys should be equal.");
        }
コード例 #2
0
        private TDST_DomainService CreateDomainService(DomainOperationType operation)
        {
            TDST_DomainService domainService = new TDST_DomainService();

            domainService.Initialize(new DomainServiceContext(new MockDataService(new MockUser("mock")), operation));

            return(domainService);
        }
コード例 #3
0
        public void SubmitChanges()
        {
            TDST_DomainService domainService = this.CreateDomainService(DomainOperationType.Submit);

            TDST_MockEntity entity = new TDST_MockEntity {
                PartitionKey = "PK", RowKey = "1"
            };
            ChangeSet changeSet = new ChangeSet(new[] { new ChangeSetEntry(1, entity, null, DomainOperation.Update)
                                                        {
                                                            HasMemberChanges = true
                                                        } });

            Assert.IsTrue(domainService.Submit(changeSet),
                          "Batched changes should have been submitted successfully.");
        }
コード例 #4
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.");
        }
コード例 #5
0
        public void CreateEntityContext()
        {
            TDST_DomainService domainService = this.CreateDomainService(DomainOperationType.Metadata);

            Assert.AreEqual(0, domainService.CreateEntityContextCount,
                            "The entity context should not have been created yet.");

            Assert.IsNotNull(domainService.MockEntityContext,
                             "The entity context should not be null.");

            Assert.AreEqual(1, domainService.CreateEntityContextCount,
                            "The entity context should have been created.");

            Assert.IsNotNull(domainService.MockEntityContext,
                             "The entity context should still not be null.");

            Assert.AreEqual(1, domainService.CreateEntityContextCount,
                            "The entity context count should still be at 1.");
        }
コード例 #6
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[].");
        }