示例#1
0
        public static async Task <CB.CloudTable> GetAsync(CB.CloudTable table)
        {
            var result = await Util.CloudRequest.Send <Dictionary <string, Object> >(Util.CloudRequest.Method.POST, CB.CloudApp.ApiUrl + "/app/" + CB.CloudApp.AppID + "/" + table, null);

            table.dictionary = result;
            return(table);
        }
示例#2
0
        public async Task x005_ShouldUpdateANewColumnInATable()
        {
            var tableName1 = CB.Test.Util.Methods._makeString();
            var tableName2 = CB.Test.Util.Methods._makeString();

            var obj  = new CB.CloudTable(tableName1);
            var obj1 = new CB.CloudTable(tableName2);

            obj = await obj.SaveAsync();

            obj1 = await obj1.SaveAsync();

            obj = await CB.CloudTable.GetAsync(obj);

            var column1 = new CB.Column("Name11", CB.DataType.Relation.ToString(), true, false);

            column1.RelatedTo = tableName2;

            obj.AddColumn(column1);

            obj = await obj.SaveAsync();

            var column2 = new CB.Column("Name11");

            obj.DeleteColumn(column2);
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
示例#3
0
        internal static bool _columnValidation(CB.Column column, CB.CloudTable cloudtable)
        {
            var defaultColumn = new List <string>();

            defaultColumn.Add("id");
            defaultColumn.Add("_id");
            defaultColumn.Add("updatedAt");
            defaultColumn.Add("createdAt");
            defaultColumn.Add("ACL");
            defaultColumn.Add("expires");

            if (cloudtable.Type == "user")
            {
                defaultColumn.Add("username");
                defaultColumn.Add("password");
                defaultColumn.Add("email");
                defaultColumn.Add("roles");
            }
            else if (cloudtable.Type == "role")
            {
                defaultColumn.Add("name");
            }

            var index = defaultColumn.IndexOf(column.Name.ToLower());

            if (index == -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        public async Task x009_ShouldNotChangeTheDataTypeOfAColumn()
        {
            var tableName = CB.Test.Util.Methods._makeString();

            var obj   = new CB.CloudTable(tableName);
            var table = await CB.CloudTable.GetAsync(obj);

            var column1 = new CB.Column("Name1", CB.DataType.Text.ToString(), true, false);

            table.AddColumn(column1);
            obj = await obj.SaveAsync();

            obj.Columns.FirstOrDefault().DataType = CB.DataType.Number.ToString();

            try
            {
                obj = await obj.SaveAsync();

                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
示例#5
0
        public async Task getDataFromServerNearFunction()
        {
            var custom     = new CB.CloudTable("CustomGeoPoint");
            var newColumn7 = new CB.Column("location");

            newColumn7.DataType = CB.DataType.GeoPoint.ToString();
            custom.AddColumn(newColumn7);
            var response = await custom.SaveAsync();

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

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

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

            search.SearchFilter = new CB.SearchFilter();
            search.SearchFilter.Near("location", loc, 1);
            var list = (List <CB.CloudObject>) await search.Search();

            if (list.Count > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.Fail("should have retrieved data");
            }
        }
示例#6
0
        public async Task x010_ShouldNotChangeTheRequiredPropertyOfDefaultColumn()
        {
            var tableName = CB.Test.Util.Methods._makeString();

            var obj     = new CB.CloudTable(tableName);
            var column1 = new CB.Column("Name1", CB.DataType.Text.ToString(), true, false);

            obj.AddColumn(column1);

            obj = await obj.SaveAsync();

            obj.Columns.First(o => o.Name == "Name1").Required = false;

            try
            {
                obj = await obj.SaveAsync();

                Assert.IsTrue(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.Fail("Cannot save a table when required of a column is changed.");
            }
        }
示例#7
0
        public async Task x011_ShouldChangeTheUniquePropertyOfUserDefinedColumn()
        {
            var tableName = CB.Test.Util.Methods._makeString();

            var obj     = new CB.CloudTable(tableName);
            var column1 = new CB.Column("Name1", CB.DataType.Text.ToString(), true, false);

            obj.AddColumn(column1);

            obj = await obj.SaveAsync();

            obj.Columns.First(o => o.Name == "Name1").Unique = true;

            try
            {
                obj = await obj.SaveAsync();

                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
示例#8
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");
            }
        }
示例#9
0
        public async Task x006_CreateDeleteTable()
        {
            Util.Keys.InitWithMasterKey();
            var tableName = CB.Test.Util.Methods._makeString();
            var obj       = new CB.CloudTable(tableName);

            obj = await obj.SaveAsync();

            obj = await obj.DeleteAsync();

            Assert.IsTrue(true);
        }
示例#10
0
        public async Task x007_CreateDeleteTable()
        {
            var tableName = CB.Test.Util.Methods._makeString();

            var obj   = new CB.CloudTable(tableName);
            var table = await CB.CloudTable.GetAsync(obj);

            var column1 = new CB.Column("city", CB.DataType.Text.ToString(), true, false);

            table.AddColumn(column1);
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
示例#11
0
        public async Task x005_CreateAddressTable()
        {
            Util.Keys.InitWithMasterKey();
            var obj  = new CB.CloudTable("Address");
            var City = new CB.Column("City");

            City.DataType = CB.DataType.Text.ToString();
            var PinCode = new CB.Column("PinCode");

            PinCode.DataType = CB.DataType.Number.ToString();
            obj.AddColumn(City);
            obj.AddColumn(PinCode);
            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
示例#12
0
        public async Task x004_CreateCompanyTable()
        {
            var obj     = new CB.CloudTable("Company");
            var Revenue = new CB.Column("Revenue");

            Revenue.DataType = CB.DataType.Number.ToString();
            var Name = new CB.Column("Name");

            Name.DataType = CB.DataType.Text.ToString();
            obj.AddColumn(Revenue);
            obj.AddColumn(Name);

            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
示例#13
0
        public async Task x002_DeleteTables()
        {
            Util.Keys.InitWithMasterKey();

            var obj = new CB.CloudTable("Address");

            CB.CloudTable table = await obj.DeleteAsync();

            obj   = new CB.CloudTable("Company");
            table = await obj.DeleteAsync();

            obj   = new CB.CloudTable("Employee");
            table = await obj.DeleteAsync();

            Assert.IsTrue(true);
        }
示例#14
0
        public async Task x010_ShouldNotChangeTheUniquePropertyOfDefaultColumn()
        {
            var tableName = CB.Test.Util.Methods._makeString();

            var obj = new CB.CloudTable(tableName);

            obj.Columns.First(o => o.Name == "id").Unique = false;

            try
            {
                obj = await obj.SaveAsync();

                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
示例#15
0
        public async Task x003_CreateEmployeeTable()
        {
            Util.Keys.InitWithMasterKey();

            var age = new CB.Column("Age");

            age.DataType = CB.DataType.Number.ToString();

            var name = new CB.Column("Name");

            name.DataType = CB.DataType.Text.ToString();

            CB.CloudTable obj = new CB.CloudTable("Employee");

            obj.AddColumn(age);
            obj.AddColumn(name);

            obj = await obj.SaveAsync();

            Assert.IsTrue(true);
        }
示例#16
0
        public async Task x008_ShouldNotRenameATable()
        {
            var obj = new CB.CloudTable(tableName);

            obj = await CB.CloudTable.GetAsync(obj);


            obj.Name = "Sample";

            try
            {
                obj = await obj.SaveAsync();

                Assert.IsFalse(true);
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }
示例#17
0
        public async Task x012_ShouldNotDeleteTheDefaultColumnOfTheTable()
        {
            var tableName = CB.Test.Util.Methods._makeString();

            var obj = new CB.CloudTable(tableName);

            obj = await obj.SaveAsync();

            obj.DeleteColumn(obj.Columns.Single(o => obj.Name == "Id"));

            try
            {
                obj = await obj.SaveAsync();

                Assert.Fail("Cannot delete the default column");
            }
            catch (CB.Exception.CloudBoostException e)
            {
                Console.WriteLine(e);
                Assert.IsTrue(true);
            }
        }