Пример #1
0
        public void DesDataSetAndDataTableDynamicKnownTypes()
        {
            var obj = DataSetAndDataTableKnownTypeSample.GetSampleInstance();

            var    serializer   = new YAXSerializer(obj.GetType(), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects);
            object gottonObject = serializer.Deserialize(serializer.Serialize(obj));

            Assert.That(obj.ToString(), Is.EqualTo(gottonObject.ToString()));
        }
Пример #2
0
        public void DataSetAndDataTableSerializationTest()
        {
            const string result =
                @"<DataSetAndDataTableKnownTypeSample>
  <TheDataTable>
    <NewDataSet>
      <TableName xmlns=""http://tableNs/"">
        <Col1>1</Col1>
        <Col2>2</Col2>
        <Col3>3</Col3>
      </TableName>
      <TableName xmlns=""http://tableNs/"">
        <Col1>y</Col1>
        <Col2>4</Col2>
        <Col3>n</Col3>
      </TableName>
    </NewDataSet>
  </TheDataTable>
  <TheDataSet>
    <MyDataSet>
      <Table1>
        <Cl1>num1</Cl1>
        <Cl2>34</Cl2>
      </Table1>
      <Table1>
        <Cl1>num2</Cl1>
        <Cl2>54</Cl2>
      </Table1>
      <Table2>
        <C1>one</C1>
        <C2>1</C2>
        <C3>1.5</C3>
      </Table2>
      <Table2>
        <C1>two</C1>
        <C2>2</C2>
        <C3>2.5</C3>
      </Table2>
    </MyDataSet>
  </TheDataSet>
</DataSetAndDataTableKnownTypeSample>";

            var serializer = new YAXSerializer(typeof(DataSetAndDataTableKnownTypeSample),
                                               YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning,
                                               YAXSerializationOptions.SerializeNullObjects);
            var got = serializer.Serialize(DataSetAndDataTableKnownTypeSample.GetSampleInstance());

            Assert.That(got, Is.EqualTo(result));
        }