public async Task AllMultiCallerOperationsTest() { var newObj = ObjectHelper.NewInstance(); var existing = await ObjectHelper.CreateNewAsync(); var objToBeDeleted = await ObjectHelper.CreateNewAsync(); var newConn = APConnection.New("sibling") .FromNewObject("object", ObjectHelper.NewInstance()) .ToNewObject("object", ObjectHelper.NewInstance()); var existingConn = await APConnection.New("sibling") .FromNewObject("object", ObjectHelper.NewInstance()) .ToNewObject("object", ObjectHelper.NewInstance()) .SaveAsync(); var toBeDeletedConn = await APConnection.New("sibling") .FromNewObject("object", ObjectHelper.NewInstance()) .ToNewObject("object", ObjectHelper.NewInstance()) .SaveAsync(); existing.Set("textfield", Guid.NewGuid().ToString()); existingConn.SetAttribute("testAttr", Guid.NewGuid().ToString()); APBatch batch = new APBatch(); batch.SaveObject(newObj); batch.SaveObject(existing); batch.SaveConnection(newConn); batch.SaveConnection(existingConn); batch.DeleteObject(objToBeDeleted); batch.DeleteConnection(toBeDeletedConn); await batch.ExecuteAsync(); Assert.AreEqual(1, batch.CreatedObjects.Count()); Assert.AreEqual(1, batch.CreatedConnections.Count()); Assert.AreEqual(1, batch.UpdatedObjects.Count()); Assert.AreEqual(1, batch.UpdatedConnections.Count()); Assert.AreEqual(1, batch.DeletedObjects.Count()); Assert.AreEqual(1, batch.DeletedConnections.Count()); }
public async Task MultiCallerWithInternalReferenceTest() { APBatch batch = new APBatch(); var newObj = ObjectHelper.NewInstance(); var objReference = batch.SaveObject(newObj); var newConn = APConnection.New("sibling") .FromNewObject("object", ObjectHelper.NewInstance()) .ToBatchObjectReference("object", objReference); var connReference = batch.SaveConnection(newConn); await batch.ExecuteAsync(); Assert.AreEqual(1, batch.CreatedObjects.Count()); Assert.AreEqual(1, batch.CreatedConnections.Count()); Assert.IsNotNull(batch.CreatedObjects[objReference]); Assert.IsNotNull(batch.CreatedConnections[connReference]); }