Пример #1
0
        public async Task LoadRefObjects()
        {
            IDataModel dm = await _dbContext.LoadModelAsync(null, "a2test.RefObjects");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TDocument,TAgent");
            md.IsItemType("TRoot", "Document", FieldType.Object);

            md.IsId("TDocument", "Id");
            md.IsItemType("TDocument", "Agent", FieldType.Object);
            md.IsItemType("TDocument", "Company", FieldType.Object);
            md.IsItemRefObject("TDocument", "Agent", "TAgent", FieldType.Object);
            md.IsItemRefObject("TDocument", "Company", "TAgent", FieldType.Object);

            md.IsId("TAgent", "Id");
            md.IsName("TAgent", null);
            md.IsType("TAgent", "Id", DataType.Number);
            md.IsType("TAgent", "Name", DataType.String);
            md.IsItemType("TAgent", "Id", FieldType.Scalar);
            md.IsItemType("TAgent", "Name", FieldType.Scalar);

            var dt = new DataTester(dm, "Document");

            dt.AreValueEqual(200, "Id");

            dt = new DataTester(dm, "Document.Agent");
            dt.AreValueEqual(300, "Id");
            dt.AreValueEqual("Agent Name", "Name");

            dt = new DataTester(dm, "Document.Company");
            dt.AreValueEqual(500, "Id");
            dt.AreValueEqual("Company Name", "Name");
        }
Пример #2
0
        public async Task LoadTreeModel()
        {
            IDataModel dm = await _dbContext.LoadModelAsync(null, "a2test.TreeModel");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TMenu");
            md.HasAllProperties("TRoot", "Menu");
            md.HasAllProperties("TMenu", "Menu,Name");
            md.IsName("TMenu", "Name");

            var dt = new DataTester(dm, "Menu");

            dt.IsArray(2);
            dt.AreArrayValueEqual("Item 1", 0, "Name");
            dt.AreArrayValueEqual("Item 2", 1, "Name");

            dt = new DataTester(dm, "Menu[0].Menu");
            dt.IsArray(2);
            dt.AreArrayValueEqual("Item 1.1", 0, "Name");
            dt.AreArrayValueEqual("Item 1.2", 1, "Name");

            dt = new DataTester(dm, "Menu[0].Menu[0].Menu");
            dt.IsArray(1);
            dt.AreArrayValueEqual("Item 1.1.1", 0, "Name");
        }
        public async Task ScalarDataTypes()
        {
            var dm = await _dbContext.LoadModelAsync(null, "a2test.[TypesModel.Load]");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TModel");
            md.HasAllProperties("TRoot", "Model");
            md.HasAllProperties("TModel", "Name,Id,Decimal,Int,BigInt,Short,Tiny,Float,Date,DateTime");
            md.IsId("TModel", "Id");
            md.IsName("TModel", "Name");

            var dt = new DataTester(dm, "Model");

            dt.AreValueEqual(123, "Id");
            dt.AreValueEqual("ObjectName", "Name");
            dt.AreValueEqual(55.1234M, "Decimal");
            dt.AreValueEqual(32, "Int");
            dt.AreValueEqual(77223344L, "BigInt");
            dt.AreValueEqual((Int16)27823, "Short");
            dt.AreValueEqual((Byte)255, "Tiny");
            dt.AreValueEqual(77.6633, "Float");
            dt.AreValueEqual(new DateTime(2018, 02, 19), "Date");
            dt.AreValueEqual(new DateTime(2018, 02, 19, 15, 10, 20), "DateTime");
        }
Пример #4
0
        public async Task LoadEmptyArray()
        {
            IDataModel dm = await _dbContext.LoadModelAsync(null, "a2test.EmptyArray2");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TElem");
            md.HasAllProperties("TRoot", "Elements");
            md.HasAllProperties("TElem", "Id,Name");
            md.IsName("TElem", "Name");
            md.IsId("TElem", "Id");

            var dt = new DataTester(dm, "Elements");

            dt.IsArray(0);
        }
        public async Task LocalizeSimpleModel()
        {
            var dm = await _dbContext.LoadModelAsync(null, "a2test.[SimpleModel.Localization.Load]");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TModel");
            md.HasAllProperties("TRoot", "Model");
            md.HasAllProperties("TModel", "Name,Id");
            md.IsId("TModel", "Id");
            md.IsName("TModel", "Name");

            var dt = new DataTester(dm, "Model");

            dt.AreValueEqual(234, "Id");
            dt.AreValueEqual("Item 1", "Name");
        }
Пример #6
0
        public async Task LoadSimpleModel()
        {
            var dm = await _dbContext.LoadModelAsync(null, "a2test.[SimpleModel.Load]");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TModel");
            md.HasAllProperties("TRoot", "Model");
            md.HasAllProperties("TModel", "Name,Id,Decimal");
            md.IsId("TModel", "Id");
            md.IsName("TModel", "Name");

            var dt = new DataTester(dm, "Model");

            dt.AreValueEqual(123, "Id");
            dt.AreValueEqual("ObjectName", "Name");
            dt.AreValueEqual(55.1234M, "Decimal");
        }
Пример #7
0
        public async Task SimplePager()
        {
            var dm = await _dbContext.LoadModelAsync(null, "a2test.[PagerModel.Load]");

            var md = new MetadataTester(dm);

            md.IsAllKeys("TRoot,TElem");
            md.HasAllProperties("TRoot", "Elems");
            md.HasAllProperties("TElem", "Name,Id");
            md.IsId("TElem", "Id");
            md.IsName("TElem", "Name");

            var dt = new DataTester(dm, "Elems");

            dt.IsArray(1);

            dt = new DataTester(dm, "$ModelInfo.Elems");
            dt.AreValueEqual(20, "PageSize");
            dt.AreValueEqual("asc", "SortDir");
            dt.AreValueEqual("Name", "SortOrder");
        }