Пример #1
0
        protected override async Task <U1Pair> RunProxiedDbDataAdapterAsync(List <TestTable> randomDataSource, FakeProxiedDbDataAdapter adapter)
        {
            using (DbCommandBuilder cmdBuilder = await adapter.CreateCommandBuilderAsync().ConfigureAwait(false))
            {
                DataSet dataSet = new DataSet();

                Int32 rowsInFirstTable = await adapter.FillAsync(dataSet);

                rowsInFirstTable.ShouldBe(40);

                //
                Dictionary <String, Int32> rowsModified = DataTableMethods.MutateDataSet(dataSet);

                List <(String tableName, String command)> executedCommands = new List <(string tableName, string command)>();

                //
                adapter.UpdateCommand = (FakeDbCommand)cmdBuilder.GetUpdateCommand();
                adapter.UpdateCommand.NonQueryResultRowCountValue = (cmd) => DataTableMethods.GetUpdateStatementNonQueryResultRowCountValue(expectedTableName: "TODO", adapter, dataSet, cmd, rowsModified, executedCommands);

                //

                Int32 updatedRows = await adapter.Update1Async(dataSet);   // updatedRows... in first table only?

//              updatedRows.ShouldBe( rowsModified );

                return(dataSet, rowsModified, updatedRows);
            }
        }
Пример #2
0
        protected override async Task <U2Pair> RunBatchingProxiedDbDataAdapterAsync(List <TestTable> randomDataSource, BatchingFakeProxiedDbDataAdapter adapter)
        {
            using (DbCommandBuilder <FakeDbCommand> cmdBuilder = await adapter.CreateCommandBuilderAsync().ConfigureAwait(false))
            {
                DataTable dataTable = new DataTable();

                // `.Fill` returns the number of rows in the first table, not any subsequent tables. Yes, that's silly.
                Int32 rowsInFirstTable = adapter.Fill(dataTable);
                rowsInFirstTable.ShouldBe(40);

                //
                Dictionary <String, Int32> rowsModified = DataTableMethods.MutateDataTable(dataTable);

                //
                adapter.UpdateCommand = cmdBuilder.GetUpdateCommand();
                adapter.UpdateCommand.NonQueryResultRowCountValue = (cmd) => DataTableMethods.GetUpdateStatementNonQueryResultRowCountValue(expectedTableName: "TODO", adapter, dataTable, cmd, rowsModified);

                DataRow[] rows = dataTable.Rows.Cast <DataRow>().ToArray();

                Int32 updatedRows = await adapter.Update2Async(rows);

//              updatedRows.ShouldBe( rowsModified );

                return(rows, rowsModified, updatedRows);
            }
        }
Пример #3
0
        // TODO: Variations of `UpdateNTest` that use custom Table/Column Mappings.
        // This is documented here: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/dataadapter-datatable-and-datacolumn-mappings
        // This would then cover the `Table`, `Table1`, etc. naming issues.

        protected override U1Pair RunDbDataAdapterSynchronous(List <TestTable> randomDataSource, FakeDbDataAdapter adapter)
        {
            using (FakeDbCommandBuilder cmdBuilder = adapter.CreateCommandBuilder())
            {
                DataSet dataSet = new DataSet();

                // `.Fill` returns the number of rows in the first table, not any subsequent tables. Yes, that's silly.
                Int32 rowsInFirstTable = adapter.Fill(dataSet);
                rowsInFirstTable.ShouldBe(40);

                //
                Dictionary <String, Int32> rowsModified = DataTableMethods.MutateDataSet(dataSet);

                List <(String tableName, String command)> executedCommands = new List <(string tableName, string command)>();

                //
                adapter.UpdateCommand = cmdBuilder.GetUpdateCommand();
                adapter.UpdateCommand.NonQueryResultRowCountValue = (cmd) => DataTableMethods.GetUpdateStatementNonQueryResultRowCountValue(expectedTableName: "TODO", adapter, dataSet, cmd, rowsModified, executedCommands);

                Int32 updatedRows = adapter.Update1(dataSet);   // updatedRows... in first table only?
//              updatedRows.ShouldBe( rowsModified );

                return(dataSet, rowsModified, updatedRows);
            }
        }
Пример #4
0
        protected override U4Pair RunProxiedDbDataAdapter(List <TestTable> randomDataSource, FakeProxiedDbDataAdapter adapter)
        {
            using (FakeDbCommandBuilder cmdBuilder = new FakeDbCommandBuilder(adapter))
            {
                DataSet dataSet = new DataSet();

                // `.Fill` returns the number of rows in the first table, not any subsequent tables. Yes, that's silly.
                Int32 rowsInFirstTable = adapter.Fill(dataSet);
                rowsInFirstTable.ShouldBe(40);

                //
                Dictionary <String, Int32> rowsModified = DataTableMethods.MutateDataSet(dataSet);

                //
                adapter.UpdateCommand = cmdBuilder.GetUpdateCommand();
                adapter.UpdateCommand.NonQueryResultRowCountValue = (cmd) => DataTableMethods.GetUpdateStatementNonQueryResultRowCountValue(expectedTableName: "TODO", adapter, dataSet, cmd, rowsModified);

                Int32 updatedRows = adapter.Update4(dataSet, srcTable: "RandomDataTable_2");
//              updatedRows.ShouldBe( rowsModified );

                return(dataSet, rowsModified, updatedRows);
            }
        }