public void TestPointers()
        {
            // setup
            var obj    = GetFakeObj();
            var result = _client.CreateObject(obj).Result;

            // check creating pointer worked
            Assert.AreEqual(obj.SomePointer.ObjectId, result.SomePointer.ObjectId);

            // move the pointer
            result.SomePointer = new MyUser {
                ObjectId = VALID_USER_ID2
            };
            _client.Update(result);
            var result2 = _client.GetObject <ParseUnitTestObj>(result.ObjectId).Result;

            Assert.AreEqual(result.SomePointer.ObjectId, result2.SomePointer.ObjectId);

            // remove the pointer
            result.SomePointer = null;
            _client.Update(result);
            var result3 = _client.GetObject <ParseUnitTestObj>(result.ObjectId).Result;

            Assert.IsNull(result3.SomePointer);

            // tear down
            _client.DeleteObject(result);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public InstagramFeed.InstagramImage GetByInstagramId(string id)
        {
            QueryResult <InstagramFeed.Parse.InstagramImage> result = _client.GetObjects <InstagramFeed.Parse.InstagramImage>(new { instagramImageId = id });

            if (result == null || result.Results == null || result.Results.Count == 0)
            {
                return(null);
            }

            // delete duplicates if found. This is a self cleaning feature to catch when the same instagram image is accidentally imported more than once.
            if (ParseSettings.Instance.ForceDeleteDuplicates && result.Results.Count > 1)
            {
                for (int i = 0; i < result.Results.Count; i++)
                {
                    if (i == 0)
                    {
                        continue;
                    }
                    var image = result.Results[i];
                    _client.DeleteObject(image);

                    // todo : log this
                }
            }

            return(this.Load(result.Results[0]));
        }