Exemple #1
0
        public void DataListModel_Create_PayLoadWithComplexObjectsArrayWithParentArray_ShouldHaveComplexObjectItems()
        {
            //------------Setup for test--------------------------
            const string Shape         = @"<DataList>
                                    <Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" >
                                        <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""None"" />
                                        <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""None"" />
                                    </Car>
                                    <Country Description=""name of Country"" IsEditable=""True"" ColumnIODirection=""Both"" />
                                    <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Both"" >
                                        <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" >
                                            <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" >
                                                <a1 Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" ></a1>
                                            </a>
                                        </a>                                        
                                    </a>
                                   </DataList>";
            const string Data          = "<DataList></DataList>";
            var          dataListModel = new DataListModel();
            var          converter     = new DataListConversionUtils();

            //------------Execute Test---------------------------
            dataListModel.Create(Data, Shape);
            var result = converter.CreateListToBindTo(dataListModel);

            //------------Assert Results-------------------------
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("Country", result[0].DisplayValue);
            Assert.AreEqual("@a", result[1].DisplayValue);
            Assert.IsTrue(result[1].IsObject);
            Assert.IsFalse(result[1].CanHaveMutipleRows);
        }
Exemple #2
0
        public void DataListModel_Create_PayLoadWithComplexObjectsArray_ShouldHaveComplexObjectItems()
        {
            //------------Setup for test--------------------------
            const string Data = @"<DataList>
	                                <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" >	
		                                <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" />
	                                </Food>
                                </DataList>";

            const string Shape         = @"<DataList>
                                  <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" >
                                    <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" />
                                  </Food>
                                </DataList>";
            var          dataListModel = new DataListModel();
            var          converter     = new DataListConversionUtils();

            //------------Execute Test---------------------------
            dataListModel.Create(Data, Shape);
            var result = converter.GetOutputs(dataListModel);

            //------------Assert Results-------------------------
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("@Food", result[0].DisplayValue);
            Assert.IsTrue(result[0].IsObject);
            Assert.IsFalse(result[0].CanHaveMutipleRows);
        }
        /// <summary>
        /// Generates the match fragments from data list.
        /// </summary>
        /// <returns></returns>
        private FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {
                var dataListModel = new DataListModel();
                dataListModel.Create(DataList, DataList);
                IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>();

                foreach (var rs in dataListModel.RecordSets)
                {
                    // build map for each column in a recordset ;)
                    foreach (var col in rs.Columns)
                    {
                        foreach (var scalar in col.Value)
                        {
                            if (!tmp.Keys.Any(a => a.Item2 == scalar.Name && a.Item1 == rs.Name))
                            {
                                tmp[new Tuple <string, string>(rs.Name, scalar.Name)] = rs.Name;
                            }
                        }
                    }
                }

                result = new FuzzyMatchVo(tmp);
            }

            return(result);
        }
        public void DataListModel_InvalidIODirection_ShouldThrow()
        {
            const string Shape = @"<DataList>
                                    <Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" >
                                        <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" />
                                        <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" />
                                    </Car>
                                   </DataList>";

            var dataListModel = new DataListModel();

            dataListModel.Create(@"<Data><Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" >
                                        <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" />
                                        <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" />
                                    </Car><Truck Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" >
                                        <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" />
                                        <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" />
                                    </Truck></Data>", Shape);


            Assert.AreEqual(1, dataListModel.RecordSets.Count);
            Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Count);
            Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Values.Count);
            var values = dataListModel.RecordSets[0].Columns.Values.First();

            Assert.AreEqual(2, values.Count);
            Assert.AreEqual(null, values[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection);
            Assert.AreEqual(false, values[0].IsEditable);
            Assert.AreEqual("Make", values[0].Name);
            Assert.AreEqual("", values[0].Value);

            Assert.AreEqual(null, values[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Output, values[1].IODirection);
            Assert.AreEqual(false, values[1].IsEditable);
            Assert.AreEqual("Model", values[1].Name);
            Assert.AreEqual("", values[1].Value);

            Assert.AreEqual(1, dataListModel.ShapeRecordSets.Count);
            Assert.AreEqual(1, dataListModel.ShapeRecordSets[0].Columns.Count);
            var col = dataListModel.ShapeRecordSets[0].Columns.First();

            values = col.Value;
            Assert.AreEqual(1, col.Key);
            Assert.AreEqual(2, values.Count);
            Assert.AreEqual("Make of vehicle", values[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection);
            Assert.AreEqual(true, values[0].IsEditable);
            Assert.AreEqual("Make", values[0].Name);
            Assert.AreEqual(null, values[0].Value);
        }
        public void DataListModel_Create_PayLoadWithComplexObjectsArray_ShouldHaveComplexObjectItems()
        {
            //------------Setup for test--------------------------
            const string Data = @"<DataList>
	                                <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" >
		                                <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" />
	                                </Food>
                                </DataList>";

            const string Shape         = @"<DataList>
                                  <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" >
                                    <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" />
                                  </Food>
                                </DataList>";
            var          dataListModel = new DataListModel();

            //------------Execute Test---------------------------
            dataListModel.Create(Data, Shape);


            Assert.AreEqual(0, dataListModel.RecordSets.Count);
            Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count);
            Assert.AreEqual(0, dataListModel.Scalars.Count);
            Assert.AreEqual(0, dataListModel.ShapeScalars.Count);


            const string expectedValue = "{\r\n  \"Description\": \"\",\r\n  \"IsEditable\": \"True\",\r\n  \"IsJson\": \"True\",\r\n  \"IsArray\": \"False\",\r\n  \"ColumnIODirection\": \"Output\",\r\n  \"FoodName\": {\r\n    \"Description\": \"\",\r\n    \"IsEditable\": \"True\",\r\n    \"IsJson\": \"True\",\r\n    \"IsArray\": \"False\",\r\n    \"ColumnIODirection\": \"None\"\r\n  }\r\n}";

            Assert.AreEqual(1, dataListModel.ComplexObjects.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("@Food", dataListModel.ComplexObjects[0].Name);
            Assert.AreEqual(expectedValue, dataListModel.ComplexObjects[0].Value);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Output, dataListModel.ComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable);
            Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent);
            Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count);


            Assert.AreEqual(1, dataListModel.ShapeComplexObjects.Count);
            Assert.AreEqual("", dataListModel.ShapeComplexObjects[0].Description);
            Assert.AreEqual("@Food", dataListModel.ShapeComplexObjects[0].Name);
            Assert.AreEqual(expectedValue, dataListModel.ShapeComplexObjects[0].Value);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Output, dataListModel.ShapeComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsEditable);
            Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Parent);
            Assert.AreEqual(0, dataListModel.ShapeComplexObjects[0].Children.Count);
        }
        public void DataListModel_DataXmlWithNoShape_Success()
        {
            var dataListModel = new DataListModel();

            dataListModel.Create(@"" +
                                 @"<Country Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />" +
                                 @"<Food Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />"
                                 , "<datalist></datalist>");

            Assert.AreEqual(0, dataListModel.Scalars.Count);
            Assert.AreEqual(0, dataListModel.ShapeScalars.Count);
            Assert.AreEqual(0, dataListModel.ComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.ShapeComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.RecordSets.Count);
            Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count);
        }
Exemple #7
0
        public void DataListModel_Create_PayLoadWithComplexObjectValue_ShouldMatchExpectedValue()
        {
            //------------Setup for test--------------------------
            const string Data = @"<DataList>
                                    <RequestPayload>
                                        <EmailAddress>[email protected]</EmailAddress>
                                        <FirstName>Sune</FirstName>
                                        <DisplayNumber>TU00000</DisplayNumber>
                                        <MobilePhone>27832640</MobilePhone>
                                    </RequestPayload>
                                </DataList>";

            const string Shape         = @"
                                <DataList>
                                    <RequestPayload Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Input"">
                                    <EmailAddress Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></EmailAddress>    
                                    <FirstName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></FirstName>
                                    <DisplayNumber Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></DisplayNumber>
                                    <MobilePhone Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></MobilePhone>                               
                                    </RequestPayload>
                                </DataList>";
            var          dataListModel = new DataListModel();

            //------------Execute Test---------------------------
            dataListModel.Create(Data, Shape);


            Assert.AreEqual(0, dataListModel.RecordSets.Count);
            Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count);
            Assert.AreEqual(0, dataListModel.Scalars.Count);
            Assert.AreEqual(0, dataListModel.ShapeScalars.Count);


            const string expectedValue = "{\r\n  \"EmailAddress\": \"[email protected]\",\r\n  \"FirstName\": \"Sune\",\r\n  \"DisplayNumber\": \"TU00000\",\r\n  \"MobilePhone\": \"27832640\"\r\n}";

            Assert.AreEqual(1, dataListModel.ComplexObjects.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("@RequestPayload", dataListModel.ComplexObjects[0].Name);
            Assert.AreEqual(expectedValue, dataListModel.ComplexObjects[0].Value);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Input, dataListModel.ComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable);
            Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent);
            Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count);
        }
Exemple #8
0
        public void DataListConversionUtilTest_CreateListToBindTo_WhenScalarHasNoneMapping_ExpectCollectionWithNoItems()

        {
            //------------Setup for test--------------------------
            var converter = new DataListConversionUtils();

            const string Data  = "<DataList></DataList>";
            const string Shape = @"<DataList><scalar Description="""" IsEditable=""True"" ColumnIODirection=""None"" ></scalar></DataList>";

            //------------Execute Test---------------------------
            var bdl = new DataListModel();

            bdl.Create(Data, Shape);
            var result = converter.CreateListToBindTo(bdl);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, result.Count);
        }
        // ReSharper disable InconsistentNaming
        public void DataListConversionUtilTest_CreateListToBindTo_WhenScalarHasInputMapping_ExpectCollectionWithOneItem()
        // ReSharper restore InconsistentNaming
        {
            //------------Setup for test--------------------------
            var converter = new DataListConversionUtils();

            const string Data  = "<DataList></DataList>";
            const string Shape = @"<DataList><scalar Description="""" IsEditable=""True"" ColumnIODirection=""Input"" ></scalar></DataList>";

            //------------Execute Test---------------------------
            var bdl = new DataListModel();

            bdl.Create(Data, Shape);
            var result = converter.CreateListToBindTo(bdl);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("scalar", result[0].Field);
        }
        FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {
                var dataListModel = new DataListModel();
                dataListModel.Create(DataList, DataList);
                IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>();

                foreach (var rs in dataListModel.RecordSets)
                {
                    MapRecordsetColumn(tmp, rs);
                }
                result = new FuzzyMatchVo(tmp);
            }

            return(result);
        }
Exemple #11
0
        public void DataListModel_Create_PayLoadWithComplexObjects_ShouldHaveComplexObjectItems()
        {
            //------------Setup for test--------------------------
            const string Data          = "<DataList></DataList>";
            var          dataListModel = new DataListModel();
            var          converter     = new DataListConversionUtils();

            //------------Execute Test---------------------------
            dataListModel.Create(Data, Shape);
            var result = converter.CreateListToBindTo(dataListModel);

            //------------Assert Results-------------------------
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("Country", result[0].DisplayValue);
            Assert.AreEqual("@Person", result[1].DisplayValue);
            Assert.IsTrue(result[1].IsObject);
        }
Exemple #12
0
        public void DataListConversionUtilTest_CreateListToBindTo_WhenColumnHasInputMapping_ExpectCollectionWithOneItem()

        {
            //------------Setup for test--------------------------
            var converter = new DataListConversionUtils();

            const string Data  = "<DataList></DataList>";
            const string Shape = @"<DataList><rec Description="""" IsEditable=""True"" ColumnIODirection=""None"" ><a Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /><b Description="""" IsEditable=""True"" ColumnIODirection=""None"" /></rec></DataList>";

            //------------Execute Test---------------------------
            var bdl = new DataListModel();

            bdl.Create(Data, Shape);
            var result = converter.CreateListToBindTo(bdl);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("rec", result[0].Recordset);
            Assert.AreEqual("a", result[0].Field);
        }
Exemple #13
0
        public void DataListModel_DataXmlWithNoRoot_Success()
        {
            var dataListModel = new DataListModel();

            dataListModel.Create(@"" +
                                 @"<Country Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />" +
                                 @"<Food Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />"
                                 , "<datalist><Country /><Food /></datalist>");

            Assert.AreEqual(2, dataListModel.Scalars.Count);
            Assert.AreEqual("", dataListModel.Scalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable);
            Assert.AreEqual("Country", dataListModel.Scalars[0].Name);
            Assert.AreEqual("", dataListModel.Scalars[0].Value);

            Assert.AreEqual("", dataListModel.Scalars[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[1].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[1].IsEditable);
            Assert.AreEqual("Food", dataListModel.Scalars[1].Name);
            Assert.AreEqual("", dataListModel.Scalars[1].Value);

            Assert.AreEqual(2, dataListModel.ShapeScalars.Count);

            Assert.AreEqual("", dataListModel.Scalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable);
            Assert.AreEqual("Country", dataListModel.Scalars[0].Name);
            Assert.AreEqual("", dataListModel.Scalars[0].Value);

            Assert.AreEqual("", dataListModel.Scalars[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[1].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[1].IsEditable);
            Assert.AreEqual("Food", dataListModel.Scalars[1].Name);
            Assert.AreEqual("", dataListModel.Scalars[1].Value);

            Assert.AreEqual(0, dataListModel.ComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.ShapeComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.RecordSets.Count);
            Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count);
        }
        public IServiceTestModel CreateTest(IResourceModel resourceModel, int testNumber, bool isFromDebug)
        {
            var testModel = new ServiceTestModel(resourceModel.ID)
            {
                TestName          = "Test " + (testNumber == 0 ? 1 : testNumber),
                TestPending       = true,
                Enabled           = true,
                NewTest           = true,
                NoErrorExpected   = true,
                ErrorExpected     = false,
                ErrorContainsText = string.Empty,
                Inputs            = new ObservableCollection <IServiceTestInput>(),
                Outputs           = new ObservableCollection <IServiceTestOutput>(),
            };

            if (!string.IsNullOrEmpty(resourceModel.DataList))
            {
                DataList = new DataListModel();
                DataList.Create(resourceModel.DataList, resourceModel.DataList);
                var inputList  = _dataListConversionUtils.GetInputs(DataList);
                var outputList = _dataListConversionUtils.GetOutputs(DataList);
                testModel.Inputs = inputList.Select(sca =>
                {
                    var serviceTestInput          = new ServiceTestInput(sca.DisplayValue, "");
                    serviceTestInput.AddNewAction = () => testModel.AddRow(serviceTestInput, DataList);
                    return((IServiceTestInput)serviceTestInput);
                }).ToObservableCollection();
                if (!isFromDebug)
                {
                    testModel.Outputs = outputList.Select(sca =>
                    {
                        var serviceTestOutput          = new ServiceTestOutput(sca.DisplayValue, "", "", "");
                        serviceTestOutput.AddNewAction = () => testModel.AddRow(serviceTestOutput, DataList);
                        return((IServiceTestOutput)serviceTestOutput);
                    }).ToObservableCollection();
                }
            }
            testModel.Item = (ServiceTestModel)testModel.Clone();
            return(testModel);
        }
Exemple #15
0
        public void DataListModel_DataXmlWithSystemTag_GivenOutputIODirection_NotAdded()
        {
            var dataListModel = new DataListModel();

            dataListModel.Create(@"" +
                                 @"<WebServerUrl Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""Output"" />" +
                                 @"<Food Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""Output"" />"
                                 , "<datalist><WebServerUrl /><Food /></datalist>");

            Assert.AreEqual(1, dataListModel.Scalars.Count);
            Assert.AreEqual(1, dataListModel.ShapeScalars.Count);
            Assert.AreEqual(0, dataListModel.ComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.ShapeComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.RecordSets.Count);
            Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count);


            Assert.AreEqual("", dataListModel.Scalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable);
            Assert.AreEqual("Food", dataListModel.Scalars[0].Name);
            Assert.AreEqual("", dataListModel.Scalars[0].Value);
        }
Exemple #16
0
        public void DataListModel_InvalidXml_ShouldThrow()
        {
            var dataListModel = new DataListModel();

            dataListModel.Create("<b", Shape);
        }
Exemple #17
0
        public void DataListModel_EmptyData()
        {
            var dataListModel = new DataListModel();

            dataListModel.Create("", Shape);

            // verify
            Assert.AreEqual(1, dataListModel.RecordSets.Count);
            Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Count);
            Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Values.Count);
            var values = dataListModel.RecordSets[0].Columns.Values.First();

            Assert.AreEqual(2, values.Count);
            Assert.AreEqual("Make of vehicle", values[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, values[0].IODirection);
            Assert.AreEqual(true, values[0].IsEditable);
            Assert.AreEqual("Make", values[0].Name);
            Assert.AreEqual(null, values[0].Value);

            Assert.AreEqual("Model of vehicle", values[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, values[1].IODirection);
            Assert.AreEqual(true, values[1].IsEditable);
            Assert.AreEqual("Model", values[1].Name);
            Assert.AreEqual(null, values[1].Value);

            Assert.AreEqual(1, dataListModel.ComplexObjects.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("@Person", dataListModel.ComplexObjects[0].Name);
            Assert.AreEqual(null, dataListModel.ComplexObjects[0].Value);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable);
            Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent);
            Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count);

            Assert.AreEqual(1, dataListModel.Scalars.Count);
            Assert.AreEqual("name of Country", dataListModel.Scalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.Scalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable);
            Assert.AreEqual("Country", dataListModel.Scalars[0].Name);
            Assert.AreEqual(null, dataListModel.Scalars[0].Value);

            Assert.AreEqual(1, dataListModel.ShapeComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.ShapeComplexObjects[0].Children.Count);
            Assert.AreEqual("", dataListModel.ShapeComplexObjects[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ShapeComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsEditable);
            Assert.AreEqual("@Person", dataListModel.ShapeComplexObjects[0].Name);
            Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Parent);
            Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Value);

            Assert.AreEqual(1, dataListModel.ShapeRecordSets.Count);
            Assert.AreEqual(1, dataListModel.ShapeRecordSets[0].Columns.Count);
            var col = dataListModel.ShapeRecordSets[0].Columns.First();

            values = col.Value;
            Assert.AreEqual(1, col.Key);
            Assert.AreEqual(2, values.Count);
            Assert.AreEqual("Make of vehicle", values[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, values[0].IODirection);
            Assert.AreEqual(true, values[0].IsEditable);
            Assert.AreEqual("Make", values[0].Name);
            Assert.AreEqual(null, values[0].Value);

            Assert.AreEqual("Model of vehicle", values[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.None, values[1].IODirection);
            Assert.AreEqual(true, values[1].IsEditable);
            Assert.AreEqual("Model", values[1].Name);
            Assert.AreEqual(null, values[1].Value);

            Assert.AreEqual(1, dataListModel.ShapeScalars.Count);
            Assert.AreEqual("name of Country", dataListModel.ShapeScalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ShapeScalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.ShapeScalars[0].IsEditable);
            Assert.AreEqual("Country", dataListModel.ShapeScalars[0].Name);
            Assert.AreEqual(null, dataListModel.ShapeScalars[0].Value);
        }
Exemple #18
0
        public void DataListModel_Create_PayLoadWithComplexObjectsArrayWithParentArray_ShouldHaveComplexObjectItems()
        {
            const string Shape         = @"<DataList>
                                    <Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" >
                                        <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" />
                                        <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" />
                                    </Car>
                                    <Country Description=""name of Country"" IsEditable=""True"" ColumnIODirection=""Both"" />
                                    <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Both"" >
                                        <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" >
                                            <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" >
                                                <a1 Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" ></a1>
                                            </a>
                                        </a>
                                    </a>
                                   </DataList>";
            const string Data          = "<DataList></DataList>";
            var          dataListModel = new DataListModel();

            // test
            dataListModel.Create(Data, Shape);

            // verify
            Assert.AreEqual(1, dataListModel.RecordSets.Count);
            Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Count);
            Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Values.Count);
            var values = dataListModel.RecordSets[0].Columns.Values.First();

            Assert.AreEqual(2, values.Count);
            Assert.AreEqual("Make of vehicle", values[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection);
            Assert.AreEqual(true, values[0].IsEditable);
            Assert.AreEqual("Make", values[0].Name);
            Assert.AreEqual(null, values[0].Value);

            Assert.AreEqual("Model of vehicle", values[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Output, values[1].IODirection);
            Assert.AreEqual(true, values[1].IsEditable);
            Assert.AreEqual("Model", values[1].Name);
            Assert.AreEqual(null, values[1].Value);

            Assert.AreEqual(1, dataListModel.ComplexObjects.Count);
            Assert.AreEqual("", dataListModel.ComplexObjects[0].Description);
            Assert.AreEqual("@a", dataListModel.ComplexObjects[0].Name);
            Assert.AreEqual(null, dataListModel.ComplexObjects[0].Value);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable);
            Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent);
            Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count);

            Assert.AreEqual(1, dataListModel.Scalars.Count);
            Assert.AreEqual("name of Country", dataListModel.Scalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.Scalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable);
            Assert.AreEqual("Country", dataListModel.Scalars[0].Name);
            Assert.AreEqual(null, dataListModel.Scalars[0].Value);

            Assert.AreEqual(1, dataListModel.ShapeComplexObjects.Count);
            Assert.AreEqual(0, dataListModel.ShapeComplexObjects[0].Children.Count);
            Assert.AreEqual("", dataListModel.ShapeComplexObjects[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ShapeComplexObjects[0].IODirection);
            Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsArray);
            Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsEditable);
            Assert.AreEqual("@a", dataListModel.ShapeComplexObjects[0].Name);
            Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Parent);
            Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Value);

            Assert.AreEqual(1, dataListModel.ShapeRecordSets.Count);
            Assert.AreEqual(1, dataListModel.ShapeRecordSets[0].Columns.Count);
            var col = dataListModel.ShapeRecordSets[0].Columns.First();

            values = col.Value;
            Assert.AreEqual(1, col.Key);
            Assert.AreEqual(2, values.Count);
            Assert.AreEqual("Make of vehicle", values[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection);
            Assert.AreEqual(true, values[0].IsEditable);
            Assert.AreEqual("Make", values[0].Name);
            Assert.AreEqual(null, values[0].Value);

            Assert.AreEqual("Model of vehicle", values[1].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Output, values[1].IODirection);
            Assert.AreEqual(true, values[1].IsEditable);
            Assert.AreEqual("Model", values[1].Name);
            Assert.AreEqual(null, values[1].Value);


            Assert.AreEqual(1, dataListModel.ShapeScalars.Count);
            Assert.AreEqual("name of Country", dataListModel.ShapeScalars[0].Description);
            Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ShapeScalars[0].IODirection);
            Assert.AreEqual(true, dataListModel.ShapeScalars[0].IsEditable);
            Assert.AreEqual("Country", dataListModel.ShapeScalars[0].Name);
            Assert.AreEqual(null, dataListModel.ShapeScalars[0].Value);
        }