Example #1
0
        public async Task BulkDeleteConnectionTest()
        {
            // Create a new connection
            var conn1 = await ConnectionHelper.CreateNew();

            var conn2 = await ConnectionHelper.CreateNew();

            // Delete the connection
            await APConnections.MultiDeleteAsync(conn1.Type, new[] { conn1.Id, conn2.Id });

            // Try and get the connection
            try
            {
                var read = await APConnections.GetAsync(conn1.Type, conn1.Id);

                Assert.Fail("No exception was raised on reading deleted connection.");
            }
            catch (ObjectNotFoundException)
            {
            }

            try
            {
                var read = await APConnections.GetAsync(conn2.Type, conn2.Id);

                Assert.Fail("No exception was raised on reading deleted connection.");
            }
            catch (ObjectNotFoundException)
            {
            }
        }
Example #2
0
        public async Task UpdateConnectionAsyncTest()
        {
            dynamic conn = APConnection
                           .New("sibling")
                           .FromNewObject("object", ObjectHelper.NewInstance())
                           .ToNewObject("object", ObjectHelper.NewInstance());

            conn.field1 = "test";
            conn.field2 = 15L;
            await conn.SaveAsync();

            Console.WriteLine("Created connection with id: {0}", conn.Id);

            // Update the connection
            conn.field1 = "updated";
            conn.field2 = 11L;
            await conn.SaveAsync();

            // Get the connection
            APConnection read = await APConnections.GetAsync("sibling", conn.Id);

            // Asserts
            Assert.IsTrue(read.Get <string>("field1") == "updated");
            Assert.IsTrue(read.Get <int>("field2") == 11L);
        }
Example #3
0
        public async Task GetConnectionAsyncTest()
        {
            // Create a new connection
            var conn = await ConnectionHelper.CreateNew();

            var read = await APConnections.GetAsync(conn.Type, conn.Id);

            Assert.IsTrue(read != null);
            Assert.IsTrue(read.Id == conn.Id);
            Assert.IsTrue(conn.Endpoints.ToArray().Select(x => x.ObjectId).Intersect(read.Endpoints.ToArray().Select(x => x.ObjectId)).Count() == 2);
        }
Example #4
0
        public async Task DeleteConnectionAsyncTest()
        {
            // Create a new connection
            var conn = await ConnectionHelper.CreateNew();

            // Delete the connection
            await APConnections.DeleteAsync(conn.Type, conn.Id);

            // Try and get the connection
            try
            {
                var read = await APConnections.GetAsync(conn.Type, conn.Id);

                Assert.Fail("No exception was raised on reading deleted connection.");
            }
            catch (ObjectNotFoundException)
            {
            }
        }
Example #5
0
        public async Task UpdatePartialConnectionAsyncTest()
        {
            // Create new connection
            var obj1 = await ObjectHelper.CreateNewAsync();

            var obj2 = new APObject("object");
            var conn = APConnection
                       .New("sibling")
                       .FromExistingObject("object", obj1.Id)
                       .ToNewObject("object", obj2);
            await conn.SaveAsync();

            // Update
            var conn2 = new APConnection("sibling", conn.Id);
            var value = Guid.NewGuid().ToString();

            conn["field1"] = value;
            await conn.SaveAsync();

            var updated = await APConnections.GetAsync("sibling", conn.Id);

            Assert.IsTrue(updated.Get <string>("field1") == value);
        }