Пример #1
0
        public async Task MaintainOrderofSavedRelations()
        {
            var obj1 = new CB.CloudObject("Hostel");

            obj1.Set("room", 123);
            obj1 = await obj1.SaveAsync();

            int room = obj1.Get <int>("room");

            if (room == 123)
            {
                obj1.Unset("room");
                obj1 = await obj1.SaveAsync();

                if (obj1.Get("room") == null)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.IsFalse(true);
                }
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Пример #2
0
        public async Task updateObject()
        {
            CB.Test.Util.Keys.InitWithClientKey();
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            await obj.SaveAsync();

            if (obj.Get("name").ToString() != "sample")
            {
                Assert.IsFalse(true);
            }
            else if (obj.ID == null)
            {
                Assert.IsFalse(true);
            }

            obj.Set("name", "sample1");
            await obj.SaveAsync();

            if (obj.Get("name").ToString() != "sample1")
            {
                Assert.IsFalse(true);
            }
            else if (obj.ID == null)
            {
                Assert.IsFalse(true);
            }

            Assert.IsTrue(true);
        }
Пример #3
0
        public async Task UpdateObject()
        {
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            await obj.SaveAsync();

            if (obj.Get("name").ToString() != "sample")
            {
                Assert.IsFalse(true);
            }
            else if (obj.ID == null)
            {
                Assert.IsFalse(true);
            }

            obj.Set("name", "sample1");
            await obj.SaveAsync();

            if (obj.Get("name").ToString() != "sample1")
            {
                Assert.IsFalse(true);
            }
            else if (obj.ID == null)
            {
                Assert.IsFalse(true);
            }

            Assert.IsTrue(true);
        }
Пример #4
0
        public async Task UnsetField()
        {
            var obj1 = new CB.CloudObject("Hostel");

            obj1.Set("room", 123);
            obj1 = await obj1.SaveAsync();

            string room = obj1.Get("room").ToString();

            if (room == "123")
            {
                obj1.Unset("room");
                obj1 = await obj1.SaveAsync();

                if (obj1.Get("room") == null)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.IsTrue(false);
                }
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Пример #5
0
        public async Task DoNotSaveDuplicateRelationInUniqueField()
        {
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            var obj1 = new CB.CloudObject("Sample");

            obj1.Set("name", "sample");
            obj.Set("uniqueRelation", obj1);
            await obj.SaveAsync();

            var obj2 = new CB.CloudObject("Sample");

            obj2.Set("name", "sample");
            obj2.Set("uniqueRelation", obj.Get("uniqueRelation"));

            try
            {
                await obj2.SaveAsync();

                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
Пример #6
0
        public async Task saveFileDataAndNameThenFetch()
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes(".net cloudfile testing!");
            string name = "sample.txt";
            string type = "txt";
            var    file = new CB.CloudFile(data, name, type);
            await file.SaveAsync();

            var obj = new CB.CloudObject("Sample");

            obj.Set("file", file);
            obj.Set("name", "abcd");
            await obj.SaveAsync();

            var fileObj = (CB.CloudFile)obj.Get("file");

            if (fileObj.Url != null)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("Unable to fetch the file");
            }
        }
Пример #7
0
        public async Task EqualToWithCloudSearchOverCloudObject()
        {
            var custom     = new CB.CloudTable("CustomRelation");
            var newColumn1 = new CB.Column("newColumn7");

            newColumn1.DataType = CB.DataType.Relation.ToString();
            custom.AddColumn(newColumn1);
            await custom.SaveAsync();

            var loc  = new CB.CloudGeoPoint(17.7, 80.0);
            var obj  = new CB.CloudObject("CustomRelation");
            var obj1 = new CB.CloudObject("student1");

            obj1.Set("name", "Ranjeet");
            obj.Set("newColumn7", obj1);
            await obj.SaveAsync();

            var search = new CB.CloudSearch("CustomRelation");

            search.SearchFilter = new CB.SearchFilter();
            search.SearchFilter.EqualTo("newColumn7", obj.Get("newColumn7"));
            var list = (List <CB.CloudObject>) await search.Search();

            if (list.Count > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("should have retrieved data");
            }
        }
Пример #8
0
        public async Task returnFileWithCloudObject()
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes(".net cloudfile testing!");
            string name = "sample.txt";
            string type = "txt";
            var    file = new CB.CloudFile(data, name, type);
            await file.SaveAsync();

            if (file.Url != null)
            {
                var obj = new CB.CloudObject("Company");
                obj.Set("File", file);
                await obj.SaveAsync();

                var fileObj = (CB.CloudFile)obj.Get("File");
                if (fileObj.Url != null)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.Fail("Did not get the file object back.");
                }
            }
        }
Пример #9
0
        public async Task GetEncryptedPasswordOverORQuery()
        {
            var username = Util.Methods.MakeEmail();
            var obj      = new CB.CloudObject("User");

            obj.Set("username", username);
            obj.Set("password", "password");
            obj.Set("email", username);
            await obj.SaveAsync();

            string pass = obj.Get("password").ToString();

            if (!pass.Equals("password"))
            {
                var query1 = new CB.CloudQuery("User");
                query1.EqualTo("password", "password");

                var query2 = new CB.CloudQuery("User");
                query2.EqualTo("password", "password1");

                var query = CB.CloudQuery.Or(query1, query2);
                query.EqualTo("username", username);
                ArrayList response = await query.FindAsync();

                if (response.Count > 0)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.IsFalse(true);
                }
            }
        }
Пример #10
0
        public async Task GetEncryptedPassword()
        {
            string username = Util.Methods.MakeEmail();
            var    obj      = new CB.CloudObject("User");

            obj.Set("username", username);
            obj.Set("password", "password");
            obj.Set("email", Util.Methods.MakeEmail());
            await obj.SaveAsync();

            if (obj.Get("password").ToString() != "password")
            {
                var query = new CB.CloudQuery("User");
                query.EqualTo("password", "password");
                query.EqualTo("username", username);
                var response = await query.FindAsync();

                if (response.Count > 0)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.Fail("Cannot get items");
                }
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Пример #11
0
        public async Task shouldModifyListRelationOfSavedObject()
        {
            var obj1 = new CB.CloudObject("Sample");

            obj1.Set("name", "sample");
            var obj2 = new CB.CloudObject("Sample");

            obj2.Set("name", "sample");
            CB.CloudObject[] objects = { obj1, obj2 };
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            obj.Set("relationArray", objects);
            obj = await obj.SaveAsync();

            CB.CloudObject[] relationArray = (CB.CloudObject[])obj.Get("relationArray");
            if (relationArray.Length != 2)
            {
                Assert.IsFalse(true);
            }
            obj.Set("relationArray", relationArray);
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
Пример #12
0
        public async Task saveObject()
        {
            var obj = new CB.CloudObject("student1");

            obj.Set("name", "ranjeet");
            await obj.SaveAsync();

            if (obj.Get("name").ToString() == "ranjeet")
            {
                Assert.IsTrue(true);
            }

            Assert.IsFalse(true);
        }
Пример #13
0
        public async Task fetchCloudObject()
        {
            var obj1 = new CB.CloudObject("Custom18");

            obj1.Set("number", 0);
            obj1 = await obj1.SaveAsync();

            obj1 = await obj1.FetchAsync();

            if ((int)obj1.Get("number") == 0)
            {
                Assert.IsTrue(true);
            }
            Assert.IsFalse(true);
        }
Пример #14
0
        public void setModifiedArray()
        {
            var obj = new CB.CloudObject("sample");

            obj.Set("expires", 0);
            obj.Set("name", "ranjeet");
            if (((ArrayList)obj.Get("_modifiedColumns")).Count > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Пример #15
0
        public async Task saveRelationWithRelateFunction()
        {
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            var obj1 = new CB.CloudObject("Sample");

            obj1.Set("name", "sample");
            obj1 = await obj1.SaveAsync();

            obj.Relate("sameRelation", "Sample", obj1.Get("id").ToString());
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
Пример #16
0
        public async Task saveRelation()
        {
            var obj1 = new CB.CloudObject("hostel");

            obj1.Set("room", 123);
            obj1 = await obj1.SaveAsync();

            var obj = new CB.CloudObject("student1");

            var obj2 = new CB.CloudObject("hostel", obj1.Get("id").ToString());

            obj.Set("newColumn", obj2);
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
Пример #17
0
        public async Task saveRelationWithoutChildObject()
        {
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "ranjeet");
            obj = await obj.SaveAsync();

            if (obj.Get("name").ToString() == (string)"ranjeet")
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Пример #18
0
        public async Task KeepRelationIntact()
        {
            var obj = new CB.CloudObject("Custom2");

            obj.Set("newColumn2", new CB.CloudObject("student1"));
            obj.Set("newColumn7", new CB.CloudObject("student1"));
            obj = await obj.SaveAsync();

            if (((CB.CloudObject)obj.Get("newColumn2")).TableName == "student1")
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Пример #19
0
        public async Task FetchCloudObject()
        {
            var obj1 = new CB.CloudObject("Custom18");

            obj1.Set("number", 0);
            obj1 = await obj1.SaveAsync();

            obj1 = await obj1.FetchAsync();

            if (obj1.Get("number").ToString() == "0")
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Пример #20
0
        public async Task shouldNotDuplicateValuesInListAfterUpdate()
        {
            var obj = new CB.CloudObject("student1");

            obj.Set("age", 5);
            obj.Set("name", "abcd");
            var obj1 = new CB.CloudObject("Custom4");

            CB.CloudObject[] objects = { obj, obj };
            obj1.Set("newColumn7", objects);
            obj1 = await obj1.SaveAsync();

            CB.CloudObject[] arr = (CB.CloudObject[])obj.Get("newColumn7");
            if (arr.Length != 2)
            {
                Assert.IsTrue(true);
            }
        }
Пример #21
0
        public async Task SaveData()
        {
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            obj = await obj.SaveAsync();

            string name = obj.Get("name").ToString();

            if (name != "sample")
            {
                Assert.IsFalse(true);
            }
            if (obj.ID == null)
            {
                Assert.IsFalse(true);
            }
            Assert.IsTrue(true);
        }
Пример #22
0
        public async Task unsetField()
        {
            CB.Test.Util.Keys.InitWithClientKey();
            var obj1 = new CB.CloudObject("hostel");

            obj1.Set("room", 123);
            obj1 = await obj1.SaveAsync();

            string room = obj1.Get("room").ToString();

            if (room == "123")
            {
                obj1.Unset("room");
                await obj1.SaveAsync();

                Assert.IsTrue(true);
            }
            Assert.IsFalse(true);
        }
Пример #23
0
        public async Task save()
        {
            CB.Test.Util.Keys.InitWithClientKey();
            var obj = new CB.CloudObject("Sample");

            obj.Set("name", "sample");
            obj = await obj.SaveAsync();

            string name = obj.Get("name").ToString();

            if (name != "sample")
            {
                Assert.IsFalse(true);
            }
            if (obj.ID == null)
            {
                Assert.IsFalse(true);
            }
            Assert.IsTrue(true);
        }
Пример #24
0
        public async Task EncryptPassword()
        {
            var email = CB.Test.Util.Methods.MakeEmail();
            var obj   = new CB.CloudObject("User");

            obj.Set("username", email);
            obj.Set("password", "password");
            obj.Set("email", email);
            obj = await obj.SaveAsync();

            string pass = Convert.ToString(obj.Get("password"));
            string val  = "password";

            if (pass != (string)val)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(false);
            }
        }
Пример #25
0
        public async Task encryptPassword()
        {
            var email = "*****@*****.**";
            var obj   = new CB.CloudObject("User");

            obj.Set("username", email);
            obj.Set("password", "password");
            obj.Set("email", email);
            obj = await obj.SaveAsync();

            string pass = Convert.ToString(obj.Get("password"));
            string val  = "password";

            if (pass != (string)val)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(false);
            }
        }
Пример #26
0
        public async Task ShouldNotDuplicateValuesInListAfterUpdate()
        {
            var obj = new CB.CloudObject("student1");

            obj.Set("age", 5);
            obj.Set("name", "abcd");
            var       obj1    = new CB.CloudObject("Custom4");
            ArrayList objects = new ArrayList()
            {
                obj, obj
            };

            obj1.Set("newColumn7", objects);
            obj1 = await obj1.SaveAsync();

            ArrayList arr = (ArrayList)obj1.Get("newColumn7");

            if (arr.Count != 2)
            {
                Assert.IsTrue(true);
            }
        }