public void PartitionKey() { TDST_DomainService domainService = this.CreateDomainService(DomainOperationType.Metadata); Assert.AreEqual(domainService.MockPartitionKey, domainService.MockEntityContext.PartitionKey, "PartitionKeys should be equal."); }
private TDST_DomainService CreateDomainService(DomainOperationType operation) { TDST_DomainService domainService = new TDST_DomainService(); domainService.Initialize(new DomainServiceContext(new MockDataService(new MockUser("mock")), operation)); return(domainService); }
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."); }
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."); }
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."); }
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[]."); }