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

            obj1.Set("newColumn", "sample");
            obj1.Set("description", "sample2");
            await obj1.SaveAsync();

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

            obj2.Set("newColumn", "sample");
            obj2.Set("description", "sample2");
            await obj2.SaveAsync();

            var obj3 = new CB.CloudObject("Custom1");

            obj3.Set("newColumn", "sample");
            obj3.Set("description", "sample2");
            await obj3.SaveAsync();

            var       query = new CB.CloudQuery("Custom1");
            ArrayList list  = new ArrayList();

            list.Add(obj1.ID);
            list.Add(obj2.ID);
            list.Add(obj3.ID);
            query.ContainedIn("id", list);
            var response = (ArrayList)await query.FindAsync();

            Assert.IsTrue(true);
        }
Пример #2
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");
            }
        }
Пример #3
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);
            }
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
        public async Task Find()
        {
            var obj = new CB.CloudObject("Custom1");

            obj.Set("newColumn", "sample");
            obj.Set("description", "sample2");
            await obj.SaveAsync();

            var query = new CB.CloudQuery("Custom1");

            query.EqualTo("id", obj.ID);
            query.SelectColumn("newColumn");
            var response = await query.FindAsync();

            if (response.Count > 0)
            {
                if (((CB.CloudObject)response[0]).Get("description") == null)
                {
                    Assert.IsTrue(true);
                }
                else
                {
                    Assert.IsFalse(true);
                }
            }
            else
            {
                Assert.IsFalse(true);
            }
        }
Пример #6
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);
        }
Пример #7
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", obj1);

            try
            {
                await obj2.SaveAsync();

                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
Пример #8
0
        public async Task doNotSaveArrayOfDifferentCloudObjects()
        {
            var obj = new CB.CloudObject("Student");

            obj.Set("name", "sample");
            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 };
            obj.Set("relationArray", objects);
            obj = await obj.SaveAsync();

            try
            {
                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
0
        public async Task find()
        {
            CB.Test.Util.Keys.InitWithClientKey();
            var obj = new CB.CloudObject("Custom1");

            obj.Set("newColumn", "sample");
            obj.Set("description", "sample2");
            await obj.SaveAsync();

            var query = new CB.CloudQuery("Custom1");

            query.EqualTo("id", obj.ID);
            query.SelectColumn("newColumn");
            var response = (List <CB.CloudObject>) await query.FindAsync();

            if (response.Count > 0)
            {
                if (response[0].Get("description") == null)
                {
                    Assert.IsTrue(true);
                }
                Assert.IsFalse(true);
            }
            Assert.IsFalse(true);
        }
Пример #12
0
        public async Task saveFileAndGetRelation()
        {
            var obj1 = new CB.CloudObject("Employee");
            var obj2 = new CB.CloudObject("Company");

            obj1.Set("Name", "abcd");
            obj1.Set("Name", "pqrs");
            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");

            obj2.Set("File", file);
            obj1.Set("Company", obj2);
            await obj1.SaveAsync();

            var query = new CB.CloudQuery("Employee");

            query.Include("Company.File");
            query.EqualTo("id", obj1.ID);
            var response = (List <CB.CloudObject>) await query.FindAsync();

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

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

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

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

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

            obj.Set("Name", "sample");
            obj.Set("Email", "*****@*****.**");
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
Пример #16
0
        public async static Task RegisterForPushNotification(string deviceUri, string appname)
        {
            TimeZone timezone = TimeZone.CurrentTimeZone;
            var      obj      = new CB.CloudObject("Device");

            obj.Set("deviceToken", deviceUri);
            obj.Set("deviceOS", "windows");
            obj.Set("timezone", timezone);
            obj.Set("channels", Channel);
            await obj.SaveAsync();
        }
Пример #17
0
        public async Task saveArray()
        {
            string[] text = { "abcd", "abcd" };
            var      obj  = new CB.CloudObject("Sample");

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

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

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

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

            Assert.IsTrue(true);
        }
Пример #19
0
        public async Task updateGeoPoint()
        {
            var obj = new CB.CloudObject("Custom5");
            var loc = new CB.CloudGeoPoint(17.7, 78.9);

            obj.Set("location", loc);
            await obj.SaveAsync();

            Assert.IsTrue(true);
            obj.Set("latitude", 55);
            await obj.SaveAsync();

            Assert.IsTrue(true);
        }
Пример #20
0
        public async Task saveArrayWithJsonObjects()
        {
            Dictionary <string, Object> jsonObj = new Dictionary <string, object>();

            jsonObj.Add("sample", "sample");
            jsonObj.Add("sample1", "sample1");
            var obj = new CB.CloudObject("Sample");

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

            Assert.IsTrue(true);
        }
Пример #21
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);
            }
        }
Пример #22
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");
            }
        }
Пример #23
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);
            }
        }
Пример #24
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);
            }
        }
Пример #25
0
        public async Task ColumnNameNotEqualTo()
        {
            var obj = new CB.CloudObject("student1");

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

            var query = new CB.CloudQuery("student1");

            query.NotEqualTo("name", null);
            var response = await query.FindAsync();

            for (int i = 0; i < response.Count; i++)
            {
                if (((CB.CloudObject)response[i]).Get("name") == null)
                {
                    Assert.Fail("Name does not exists");
                }
            }
            if (response.Count > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("object could not queried properly");
            }
        }
Пример #26
0
        [TestMethod] //273
        public async Task RetrieveDataWithValue()
        {
            var obj = new CB.CloudObject("student1");

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

            var query = new CB.CloudQuery("student1");

            query.EqualTo("name", "sampleName");
            var response = (ArrayList)await query.FindAsync();

            if (response.Count > 0)
            {
                for (int i = 0; i < response.Count; i++)
                {
                    if (((CB.CloudObject)response[i]).Get("name").ToString() != "sampleName")
                    {
                        Assert.Fail("should retrieve saved data with particular value");
                    }
                }
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(false);
            }
        }
Пример #27
0
        public async Task RetrieveList()
        {
            var obj = new CB.CloudObject("student1");

            string[] list = { "java", "python" };
            obj.Set("subject", list);
            await obj.SaveAsync();

            var query = new CB.CloudQuery("student1");

            query.ContainsAll("subject", list);
            var response = await query.FindAsync();

            if (response.Count > 0)
            {
                for (int i = 0; i < response.Count; i++)
                {
                    ArrayList subject = (ArrayList)((CB.CloudObject)response[i]).Get("subject");
                    for (int j = 0; j < subject.Count; j++)
                    {
                        if (subject[j].ToString() != "java" && subject[j].ToString() != "python")
                        {
                            Assert.Fail("should retrieve saved data with particular value");
                        }
                    }
                }
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsFalse(false);
            }
        }
Пример #28
0
        public async Task updateSavedObject()
        {
            var obj  = new CB.CloudObject("student1");
            var obj1 = new CB.CloudObject("hostel");

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

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

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

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

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

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

            obj.Set("newColumn", obj1);
            await obj.SaveAsync();

            var query = new CB.CloudQuery("student1");

            query.NotEqualTo("newColumn", obj1);
            var response = await query.FindAsync();

            for (int i = 0; i < response.Count; i++)
            {
                if (((CB.CloudObject)response[i]).Get("newColumn") != null)
                {
                    CB.CloudObject relObj = (CB.CloudObject)((CB.CloudObject)response[i]).Get("newColumn");
                    if (relObj.ID == obj1.ID)
                    {
                        Assert.Fail("Should not get the id in not equal to");
                    }
                    Assert.IsTrue(true);
                }
            }
        }
Пример #30
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.");
                }
            }
        }