Esempio n. 1
0
        public void DataSetExchange_GetDataValues()
        {
            var dataSet = SimpleModel.MockDataSet(2);
            var dataValuesJsonString = DataSetExchange.GetDataValues(dataSet).ToJsonString(true);
            var expected             =
                @"[
   {
      ""ColumnList"" : [
         0,
         ""Name0""
      ]
   },
   {
      ""ColumnList"" : [
         1,
         ""Name1""
      ]
   }
]";

            Assert.AreEqual(expected, dataValuesJsonString);

            var columnsJsonString = DataSetExchange.GetColumns(dataSet).ToJsonString(true);
            var dataValues        = DataSetExchange.GetDataValues(dataValuesJsonString, DataSetExchange.GetColumns(columnsJsonString));

            Assert.AreEqual(expected, dataValues.ToJsonString(true));
        }
Esempio n. 2
0
        public void DataSetExchange_DataValues_GetJsonString()
        {
            var dataSet = SimpleModel.MockDataSet(2);

            var dataValuesJsonString = DataSetExchange.GetDataValues(dataSet).ToJsonString(true);
            var columnsJsonString    = DataSetExchange.GetColumns(dataSet).ToJsonString(true);
            var dataValues           = DataSetExchange.GetDataValues(dataValuesJsonString, DataSetExchange.GetColumns(columnsJsonString));
            var message = "Column editing is not supported.";

            dataValues._.ColumnList[1].SetUnsupportedMessage(message);
            var expected =
                @"[
   {
      ""ColumnList"" : [
         0
      ]
   },
   {
      ""ColumnList"" : [
         1
      ]
   }
]";

            Assert.AreEqual(expected, dataValues.GetJsonString());
        }
Esempio n. 3
0
        public void DataSetExchange_SetUnsupportedMessage()
        {
            var dataSet = SimpleModel.MockDataSet(2);

            var dataValuesJsonString = DataSetExchange.GetDataValues(dataSet).ToJsonString(true);
            var columnsJsonString    = DataSetExchange.GetColumns(dataSet).ToJsonString(true);
            var dataValues           = DataSetExchange.GetDataValues(dataValuesJsonString, DataSetExchange.GetColumns(columnsJsonString));
            var message = "Column editing is not supported.";

            dataValues._.ColumnList[1].SetUnsupportedMessage(message);
            Assert.IsFalse(dataValues._.ColumnList[1].IsSupported());
            Assert.AreEqual(message, dataValues._.ColumnList[1].GetUnsupportedMessage());
        }
Esempio n. 4
0
        public void DataSetExchange_GetColumns()
        {
            var dataSet = SimpleModel.MockDataSet(2);

            var columns  = DataSetExchange.GetColumns(dataSet);
            var expected =
                @"[
   {
      ""Type"" : ""DevZest.Data._Int32"",
      ""Name"" : ""Id""
   },
   {
      ""Type"" : ""DevZest.Data._String"",
      ""Name"" : ""Name""
   }
]";

            Assert.AreEqual(expected, columns.ToJsonString(true));
        }
Esempio n. 5
0
        public void DataSetExchange_PreviewJson()
        {
            var columnFlagsJson =
                @"[
   {
      ""IsVisible"" : true
   },
   {
      ""IsVisible"" : false
   }
]";

            var dataValuesJson =
                @"[
   {
      ""ColumnList"" : [
         0
      ]
   },
   {
      ""ColumnList"" : [
         1
      ]
   }
]";

            var result   = DataSetExchange.PreviewJson(typeof(SimpleModel).FullName, columnFlagsJson, dataValuesJson);
            var expected =
                @"[
   {
      ""Id"" : 0
   },
   {
      ""Id"" : 1
   }
]";

            Assert.AreEqual(expected, result);
        }
Esempio n. 6
0
        public void DataSetExchange_PreviewJson_strongly_typed()
        {
            var columnFlagsJson =
                @"[
   {
      ""IsVisible"" : true
   },
   {
      ""IsVisible"" : false
   }
]";

            var dataValuesJson =
                @"[
   {
      ""ColumnList"" : [
         0
      ]
   },
   {
      ""ColumnList"" : [
         1
      ]
   }
]";

            var result   = DataSetExchange._PreviewJson <SimpleModel>(columnFlagsJson, dataValuesJson);
            var expected =
                @"[
   {
      ""Id"" : 0
   },
   {
      ""Id"" : 1
   }
]";

            Assert.AreEqual(expected, result);
        }