Example #1
0
        public API()
        {
            AuthToken = string.Empty;
            IsDesktopApplication = true;
            InstalledCulture = CultureInfo.InstalledUICulture;

            _auth = new auth(this);
            _marketplace = new marketplace(this);
            _admin = new admin(this);
            _photos = new photos(this);
            _friends = new friends(this);
            _users = new users(this);
            _events = new events(this);
            _groups = new groups(this);
            _notifications = new notifications(this);
            _profile = new profile(this);
            _fbml = new fbml(this);
            _feed = new feed(this);
            _fql = new fql(this);
            _liveMessage = new liveMessage(this);
            _batch = new batch(this);
            _pages = new pages(this);
            _application = new application(this);
            _data = new data(this);
            _permissions = new permissions(this);
        }
Example #2
0
 public void createObjectTypeTest()
 {
     dropObjectTypeTest();
     API parent = _api;
     data target = new data(parent);
     string name = Constants.TestType;
     target.createObjectType(name);
     var existingTypes = target.getObjectTypes();
     foreach (var typ in existingTypes)
     {
         Assert.AreEqual(typ.name,name);
     }
 }
Example #3
0
 public void createObjectTest()
 {
     defineObjectPropertyTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     var properties = new Dictionary<string, string>
                          {
                              {
                                  Constants.TestObjectPropertyName,
                                  Constants.TestPropertyValue
                                  }
                          };
     var ret = target.createObject(obj_type, null);
     Assert.IsNotNull(ret);
     ret = target.createObject(obj_type, properties);
     _objectID = ret;
     Assert.IsNotNull(ret);
 }
Example #4
0
 public void defineAssociationTest()
 {
     DropAssociations();
     createObjectTypeTest();
     API parent = _api;
     data target = new data(parent);
     string name = Constants.TestAssociationDefName;
     int assoc_type = 2;
     assoc_object_type assoc_info1 = new assoc_object_type
                                         {
                                             alias = Constants.TestAssociationDefAlias1,
                                             object_type = Constants.TestType
                                         };
     assoc_object_type assoc_info2 = new assoc_object_type
                                         {
                                             alias = Constants.TestAssociationDefAlias2,
                                             object_type = Constants.TestType
                                         };
     bool? inverse = null;
     target.defineAssociation(name, assoc_type, assoc_info1, assoc_info2, inverse);
 }
Example #5
0
 public void setAssociationsTest()
 {
     //Does't work right now:
     //Invalid parameter: associations.
     Get2ObjectIDs();
     API parent = _api;
     data target = new data(parent);
     List<DataAssociation> assocs = new List<DataAssociation>
                                        {
                                            new DataAssociation
                                                {
                                                    assoc_time = DateTime.Now,
                                                    data = Constants.TestAssociationData1,
                                                    id1 = _id1,
                                                    id2 = _id2,
                                                    name = Constants.TestAssociationDefName
                                                },
                                            new DataAssociation
                                                {
                                                    assoc_time = DateTime.Now,
                                                    data = Constants.TestAssociationData2,
                                                    id1 = _id1,
                                                    id2 = _id2,
                                                    name = Constants.TestAssociationDefName
                                                }
                                        };
     string name = Constants.TestAssociationName;
     target.setAssociations(assocs, name);
 }
Example #6
0
 public void renameObjectTypeTest()
 {
     createObjectTypeTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     string new_name = Constants.TestTypeRename;
     target.renameObjectType(obj_type, new_name);
     var types = parent.data.getObjectTypes();
     foreach(var typ in types)
     {
         Assert.AreEqual(typ.name,new_name);
     }
 }
Example #7
0
 public void getHashValueTest()
 {
     setHashValueTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     string key = Constants.TestHashKey;
     string prop_name = Constants.TestObjectPropertyName;
     string expected = Constants.TestHashValue;
     string actual;
     actual = target.getHashValue(obj_type, key, prop_name);
     Assert.AreEqual(expected, actual);
 }
Example #8
0
 public void undefineAssociationTest()
 {
     defineAssociationTest();
     API parent = _api;
     data target = new data(parent);
     string name = Constants.TestAssociationDefName;
     target.undefineAssociation(name);
     try
     {
         target.getAssociationDefinition(name);
     }
     catch (Utility.FacebookException e)
     {
         //If it's not there, the we've we've succesfully removed the assn.
         if (e.ErrorCode != 803)
             throw e;
         //Return since we've passed
         return;
     }
     Assert.Fail("An exception should have been caught since the assn should have been removed");
 }
Example #9
0
 public void getObjectsTest()
 {
     //Currently get the following exception:
     //A database error occurred. Please try again: unable to fetch all objects.
     API parent = _api;
     data target = new data(parent);
     createObjectTest();
     long id1 = _objectID;
     createObjectTest();
     long id2 = _objectID;
     List<long> obj_ids = new List<long> {id1, id2};
     target.getObjects(obj_ids, null);
 }
Example #10
0
 public void setHashValueTest()
 {
     createObjectTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     string key = Constants.TestHashKey;
     string value = Constants.TestHashValue;
     string prop_name = Constants.TestObjectPropertyName;
     long actual = target.setHashValue(obj_type, key, value, prop_name);
     _hashID = actual;
     //Assert.IsInstanceOfType(actual, typeof(long));
     Assert.IsTrue(actual>0);
     var ret = target.getHashValue(Constants.TestType, Constants.TestHashKey, Constants.TestObjectPropertyName);
     Assert.AreEqual(ret, Constants.TestHashValue);
 }
Example #11
0
        public void setUserPreferencesTest()
        {
            API parent = _api;
            data target = new data(parent);
            List<string> values = new List<string> { Constants.TestString2, Constants.TestString3};
            bool replace = true;
            target.setUserPreferences(values, replace);
            //TODO: Figure out why there is no data coming back.  Could be a problem with the facebook api
            //for (int i = 0; i < 202; i++)
            //{
            //    var res = target.getUserPreference(i);
            //    System.Diagnostics.Debug.WriteLine(i.ToString()+ ": "+ res);
            //}
            string result1 = target.getUserPreference(0);

            Assert.AreEqual(Constants.TestString2, result1);
            string result2 = target.getUserPreference(1);
            Assert.AreEqual(Constants.TestString3, result2);
        }
Example #12
0
 public void removeAssociationsTest()
 {
     //No DataAssociation object is provided by the XSD, so this will not work.
     API parent = _api;
     data target = new data(parent);
     List<DataAssociation> assocs = null; // TODO: Initialize to an appropriate value
     string name = string.Empty; // TODO: Initialize to an appropriate value
     target.removeAssociations(assocs, name);
     //Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
Example #13
0
 public void removeAssociationTest()
 {
     setAssociationTest();
     API parent = _api;
     data target = new data(parent);
     string name = Constants.TestType;
     target.removeAssociation(name, _id1, _id2);
 }
Example #14
0
 public void incHashValueTest()
 {
     setHashValueTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     string key = Constants.TestHashKey;
     string prop_name = Constants.TestObjectPropertyName;
     int increment = 2;
     long expected = long.Parse(Constants.TestHashValue) + increment;
     long actual;
     actual = target.incHashValue(obj_type, key, prop_name,increment);
     Assert.AreEqual(expected, actual);
 }
Example #15
0
 public void removeAssociatedObjectsTest()
 {
     setAssociationTest();
     API parent = _api;
     data target = new data(parent);
     string name = Constants.TestType;
     long obj_id = _id1;
     target.removeAssociatedObjects(name, obj_id);
 }
Example #16
0
 public void getUserPreferenceTest()
 {
     setUserPreferenceTest();
     API parent = _api;
     data target = new data(parent);
     int pref_id = 0;
     string expected = Constants.TestString1;
     string actual;
     actual = target.getUserPreference(pref_id);
     Assert.AreEqual(expected, actual);
 }
Example #17
0
 public void getObjectTypeTest()
 {
     defineObjectPropertyTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     IList<object_property_info> expected = new List<object_property_info>
                                                {
                                                    new object_property_info
                                                        {
                                                            name = Constants.TestObjectPropertyName,
                                                            data_type = 2,
                                                            index_type = 0
                                                        }
                                                };
     IList<object_property_info> actual;
     actual = target.getObjectType(obj_type);
     Assert.AreEqual(expected[0].name, actual[0].name);
     Assert.AreEqual(expected[0].data_type, actual[0].data_type);
     Assert.AreEqual(expected[0].index_type, actual[0].index_type);
 }
Example #18
0
 public void getObjectTest()
 {
     API parent = _api;
     data target = new data(parent);
     createObjectTest();
     long obj_id = _objectID;
     List<string> prop_names = null;
     data_getObject_response expected = null;
     data_getObject_response actual;
 }
Example #19
0
 public void setAssociationTest()
 {
     Get2ObjectIDs();
     API parent = _api;
     data target = new data(parent);
     string name = Constants.TestType;
     string data = Constants.TestAssociationData1;
     DateTime assoc_time = DateTime.Now;
     target.setAssociation(name, _id1, _id2, data, assoc_time);
 }
Example #20
0
 public void removeHashKeysTest()
 {
     //test currently fails with the error:
     //A database error occurred. Please try again: unable to lookup hash keys.	removeHashKeysTest
     setHashValueTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     List<string> keys = new List<string>{_hashID.ToString()};
     target.removeHashKeys(obj_type, keys);
     var ret = target.getHashValue(Constants.TestType, Constants.TestHashKey, Constants.TestObjectPropertyName);
     Assert.AreEqual(ret, string.Empty);
 }
Example #21
0
 public void setCookieTest()
 {
     API parent = _api;
     data target = new data(parent);
     long uid = Constants.FBSamples_UserId;
     string cookieName = Constants.TestString1;
     string value = Constants.TestString2;
     Nullable<DateTime> expires = null;
     string path = string.Empty;
     bool expected = true;
     bool actual;
     actual = target.setCookie(uid, cookieName, value, expires, path);
     Assert.AreEqual(expected, actual);
 }
Example #22
0
        public void undefineObjectPropertyTest()
        {
            defineObjectPropertyTest();
            API parent = _api;
            data target = new data(parent);
            string obj_type = Constants.TestType;
            string prop_name = Constants.TestObjectPropertyName;

            //Check to make sure we've got just one from out setup
            var types = parent.data.getObjectType(obj_type);
            Assert.AreEqual(types.Count, 1);

            //Should have been dropped at this point.
            target.undefineObjectProperty(obj_type, prop_name);
            types = parent.data.getObjectType(obj_type);
            Assert.AreEqual(types.Count,0);
        }
Example #23
0
 public void setObjectPropertyTest()
 {
     API parent = _api;
     data target = new data(parent);
     createObjectTest();
     long obj_id = _objectID;
     string prop_name = Constants.TestObjectPropertyName;
     string prop_value = Constants.TestPropertyValue;
     target.setObjectProperty(obj_id, prop_name, prop_value);
     var typ = target.getObject(_objectID,null);
     Assert.IsTrue(typ.Untyped.Value.IndexOf(prop_value) > 0);
 }
Example #24
0
 public void getCookiesTest2()
 {
     API parent = _api;
     data target = new data(parent);
     long uid = 0; // TODO: Initialize to an appropriate value
     IList<cookie> expected = null; // TODO: Initialize to an appropriate value
     IList<cookie> actual;
     actual = target.getCookies(uid);
     Assert.AreEqual(expected, actual);
 }
Example #25
0
 public void setUserPreferenceTest()
 {
     API parent = _api;
     data target = new data(parent);
     int pref_id = 0;
     string value = Constants.TestString1;
     target.setUserPreference(pref_id, value);
     Assert.IsTrue(1 == 1);
 }
Example #26
0
 public void renameObjectPropertyTest()
 {
     defineObjectPropertyTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     string prop_name = Constants.TestObjectPropertyName;
     string new_name = Constants.TestObjectPropertyNewName;
     target.renameObjectProperty(obj_type, prop_name, new_name);
     var typ = target.getObjectType(obj_type);
     Assert.AreEqual(typ[0].name, Constants.TestObjectPropertyNewName);
 }
Example #27
0
 public void removeHashKeyTest()
 {
     setHashValueTest();
     API parent = _api;
     data target = new data(parent);
     string obj_type = Constants.TestType;
     string key = Constants.TestHashKey;
     target.removeHashKey(obj_type, key);
     var ret = target.getHashValue(Constants.TestType, Constants.TestHashKey, Constants.TestObjectPropertyName);
     Assert.AreEqual(ret, string.Empty);
 }
Example #28
0
 public void getObjectPropertyTest()
 {
     API parent = _api;
     data target = new data(parent);
     createObjectTest();
     long obj_id = _objectID;
     string prop_name = Constants.TestObjectPropertyName;
     string expected = Constants.TestPropertyValue;
     string actual;
     actual = target.getObjectProperty(obj_id, prop_name);
     Assert.AreEqual(expected, actual);
 }
Example #29
0
 public void updateObjectTest()
 {
     API parent = _api;
     data target = new data(parent);
     createObjectTest();
     long obj_id = _objectID;
     var properties = new Dictionary<string, string> { { Constants.TestObjectPropertyName, Constants.TestObjectPropertyNewName } };
     bool replace = true;
     target.updateObject(obj_id, properties, replace);
     var newObject = target.getObject(obj_id, null);
     Assert.IsTrue(newObject.Untyped.Value.IndexOf(Constants.TestObjectPropertyNewName) > 0);
 }
Example #30
0
 public void renameAssociationTest()
 {
     API parent = _api;
     data target = new data(parent);
     string name = string.Empty; // TODO: Initialize to an appropriate value
     string new_name = string.Empty; // TODO: Initialize to an appropriate value
     string new_alias1 = string.Empty; // TODO: Initialize to an appropriate value
     string new_alias2 = string.Empty; // TODO: Initialize to an appropriate value
     target.renameAssociation(name, new_name, new_alias1, new_alias2);
     //Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }