本文整理汇总了C#中Converter.ConvertToRecord方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.ConvertToRecord方法的具体用法?C# Converter.ConvertToRecord怎么用?C# Converter.ConvertToRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter.ConvertToRecord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_given_expr_refers_object_array_return_multiple_rows_with_multiple_columns_based_on_first_row
public void When_given_expr_refers_object_array_return_multiple_rows_with_multiple_columns_based_on_first_row()
{
var searchResult = JSONQuery.GetValue(jsonTestData, "Messages.Receives");
Converter converter = new Converter();
var data = converter.ConvertToRecord(searchResult);
Assert.AreEqual(data.Length, 3, "Wrong number of results");
Assert.AreEqual(data[0].FieldCount, 3, "Wrong field count of result");
// Validate column names
Assert.AreEqual(data[0].GetName(0), "Content", "1. field has invalid name");
Assert.AreEqual(data[0].GetName(1), "SendDate", "2. field has invalid name");
Assert.AreEqual(data[0].GetName(2), "AttachmentCount", "3. field has invalid name");
// 1. row data validation
Assert.AreEqual(data[0].GetString(0), "Great you?", "Invalid data on 1. column of 1. row");
Assert.AreEqual(data[0].GetDateTime(1), new DateTime(2013, 1, 21), "Invalid data on 2. column of 1. row");
Assert.AreEqual(data[0].GetDouble(2), 0, "Invalid data on 3. column of on 1. row");
// 2. row data validation
Assert.AreEqual(data[1].GetString(0), "Ok bye", "Invalid data on 1. column of 2. row");
Assert.AreEqual(data[1].GetDateTime(1), new DateTime(2013, 1, 25), "Invalid data on 2. column of 2. row");
Assert.AreEqual(data[1].GetDouble(2), 1, "Invalid data on 3. column of on 2. row");
// 3. row data validation
Assert.AreEqual(data[2].GetString(0), "Fine. Nothing new yet! You?", "Invalid data on 1. column of 3. row");
Assert.AreEqual(data[2].GetDateTime(1), new DateTime(2013, 3, 12), "Invalid data on 2. column of 3. row");
Assert.IsTrue(data[2].GetSqlDouble(2).IsNull, "Invalid data on 3. column of on 3. row");
}
示例2: When_given_expr_refers_dictionary_return_keys_as_columns
public void When_given_expr_refers_dictionary_return_keys_as_columns()
{
var searchResult = JSONQuery.GetValue(jsonTestData, "Messages[0]");
Converter converter = new Converter();
var data = converter.ConvertToRecord(searchResult);
Assert.AreEqual(data.Length, 1, "Wrong number of results");
Assert.AreEqual(data[0].FieldCount, 4, "Wrong field count of result");
// Validate column names
Assert.AreEqual(data[0].GetName(0), "Title", "1. field has invalid name");
Assert.AreEqual(data[0].GetName(1), "To", "2. field has invalid name");
Assert.AreEqual(data[0].GetName(2), "Sends", "3. field has invalid name");
Assert.AreEqual(data[0].GetName(3), "Receives", "4. field has invalid name");
// Validate row values
Assert.AreEqual(data[0].GetString(0), "Heyy", "Invalid data on 1. field");
Assert.AreEqual(data[0].GetString(1), "Thelove", "Invalid data on 2. field");
Assert.IsNotNullOrEmpty(data[0].GetString(2), "Empty data on 3. field");
Assert.IsNotNullOrEmpty(data[0].GetString(3), "Empty data on 4. field");
}
示例3: When_given_expr_refers_value_array_return_multiple_rows_with_single_column
public void When_given_expr_refers_value_array_return_multiple_rows_with_single_column()
{
var searchResult = JSONQuery.GetValue(jsonTestData, "Messages.Sends.Content");
Converter converter = new Converter();
var data = converter.ConvertToRecord(searchResult);
Assert.AreEqual(data.Length, 3, "Wrong number of results");
Assert.AreEqual(data[0].FieldCount, 1, "Wrong field count of result");
// Validate row values
Assert.AreEqual(data[0].GetString(0), "Whats up?", "Invalid data on 1. row");
Assert.AreEqual(data[1].GetString(0), "Me too. Nice to hear!", "Invalid data on 2. row");
Assert.AreEqual(data[2].GetString(0), "How is life going on?", "Invalid data on 3. row");
}
示例4: When_given_expr_refers_simple_value_return_single_row_with_single_column
public void When_given_expr_refers_simple_value_return_single_row_with_single_column()
{
var searchResult = JSONQuery.GetValue(jsonTestData, "Messages[0].Sends[0].Content");
Converter converter = new Converter();
var data = converter.ConvertToRecord(searchResult);
Assert.AreEqual(data.Length, 1, "Wrong number of results");
Assert.AreEqual(data[0].FieldCount, 1, "Wrong field count of result");
Assert.AreEqual(data[0].GetString(0), "Whats up?", "Invalid field value");
}