Exemplo n.º 1
0
        public void Write_read_and_compare_records()
        {
            var target = new SqlDatabaseClient(false)
            {
                ConnectionString = _connectionString
            };

            var deleteDataCommand = @"
DELETE [dbo].[Product];
DELETE [dbo].[Category];
DELETE [dbo].[Supplier];
";

            target.ExecuteCommand(deleteDataCommand);

            var datasetXml = @"
<dataset name=""suppliers"" setIdentityInsert=""true"" table=""Supplier"">
  <data>
    <row Id=""1"" Name=""supplier-1"" ContactName=""contact-name-1"" ContactPhone=""100-200-0001"" ContactEmail=""*****@*****.**"" />
    <row Id=""2"" Name=""supplier-2"" ContactName=""contact-name-2"" ContactPhone=""100-200-0002"" ContactEmail=""*****@*****.**"" />
    <row Id=""3"" Name=""supplier-3"" ContactName=""contact-name-3"" ContactPhone=""100-200-0003"" ContactEmail=""*****@*****.**"" />
  </data>
</dataset>
";
            var xml        = XElement.Parse(datasetXml);
            var dataset    = DatasetElement.Load(xml);

            target.WriteTable(dataset);

            var formatterManager = new FormatterManager();

            var selectRecordsQuery = "SELECT * FROM [dbo].[Supplier];";

            var actual = target.ReadTable(selectRecordsQuery, formatterManager);

            DbSafeManagerHelper.CompareDatasets(dataset, actual, new string[] { "Id" }, false, false);
        }