[TestMethod()]//INFO: there is possibility that there is no change in past two days for customer or vendor, then CDC will not return any entities. FIX: make an operation for customer and vendor before calling CDC public void CDCTest() { Customer addedCustomer = dataServiceTestCases.AddEntity(DataServiceTestHelper.CreateCustomer()) as Customer; if (addedCustomer == null || addedCustomer.Id == null) { Assert.Inconclusive("Unable to add customer to verify CDC Test"); } Vendor addedVendor = dataServiceTestCases.AddEntity(DataServiceTestHelper.CreateVendor()) as Vendor; if (addedVendor == null || addedVendor.Id == null) { Assert.Inconclusive("Unable to add vendor to verify CDC Test"); } List<IEntity> entityList = new List<IEntity>() { new Customer(), new Vendor() }; IntuitCDCResponse cdcResponse = dataServiceTestCases.CDCEntity(entityList, System.DateTime.Today.AddDays(-2)); try { List<Customer> customerList = cdcResponse.getEntity("Customer").Cast<Customer>().ToList(); Assert.IsNotNull(customerList); List<Vendor> vendorList = cdcResponse.getEntity("Vendor").Cast<Vendor>().ToList(); Assert.IsNotNull(customerList); } catch (System.Exception ex) { Assert.Fail(ex.ToString()); } }
internal static List <T> CDC <T>(ServiceContext context, T entity, DateTime changedSince) where T : IEntity { //Initializing the Dataservice object with ServiceContext DataService service = new DataService(context); List <IEntity> entityList = new List <IEntity>(); entityList.Add(entity); IntuitCDCResponse response = service.CDC(entityList, changedSince); if (response.entities.Count == 0) { return(null); } //Retrieving the entity List List <T> found = response.getEntity(entity.GetType().Name).Cast <T>().ToList(); return(found); }