コード例 #1
0
 public async Task MulticallerCanOnlyBeExecutedOnceTest()
 {
     var newObj = ObjectHelper.NewInstance();
     APBatch batch = new APBatch();
     batch.SaveObject(newObj);
     await batch.ExecuteAsync();
     try
     {
         await batch.ExecuteAsync();
         Assert.Fail("This should have failed.");
     }
     catch (AppacitiveRuntimeException)
     {
     }
 }
コード例 #2
0
 public async Task MultiCallerWithUserUpdateTest()
 {
     var user = await UserHelper.CreateNewUserAsync();
     user.SetAttribute("IsTestUser", "true");
     APBatch batch = new APBatch();
     batch.SaveObject(user);
     await batch.ExecuteAsync();
     Assert.AreEqual(1, batch.UpdatedObjects.Count());
 }
コード例 #3
0
        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());

        }
コード例 #4
0
        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]);

        }