msi/tests: Add tests for MsiViewModify ASSIGN mode.

This commit is contained in:
Hib Eris 2009-07-06 12:24:48 +02:00 committed by Alexandre Julliard
parent e13865285e
commit eaea537f0f
1 changed files with 122 additions and 0 deletions

View File

@ -4763,6 +4763,127 @@ static void test_viewmodify_update(void)
ok(r == ERROR_SUCCESS, "MsiOpenDatabase close failed\n");
}
static void test_viewmodify_assign(void)
{
MSIHANDLE hdb = 0, hview = 0, hrec = 0;
const char *query;
UINT r;
/* setup database */
DeleteFile(msifile);
r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
query = "CREATE TABLE `table` (`A` INT, `B` INT PRIMARY KEY `A`)";
r = run_query( hdb, 0, query );
ok(r == ERROR_SUCCESS, "query failed\n");
/* assign to view, new primary key */
query = "SELECT * FROM `table`";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
hrec = MsiCreateRecord(2);
ok(hrec != 0, "MsiCreateRecord failed\n");
r = MsiRecordSetInteger(hrec, 1, 1);
ok(r == ERROR_SUCCESS, "failed to set integer\n");
r = MsiRecordSetInteger(hrec, 2, 2);
ok(r == ERROR_SUCCESS, "failed to set integer\n");
r = MsiViewModify(hview, MSIMODIFY_ASSIGN, hrec);
todo_wine ok(r == ERROR_SUCCESS, "MsiViewModify failed: %d\n", r);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
r = MsiViewClose(hview);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiCloseHandle(hview);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
query = "SELECT * FROM `table`";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
r = MsiViewFetch(hview, &hrec);
todo_wine ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
r = MsiRecordGetInteger(hrec, 1);
todo_wine ok(r == 1, "Expected 1, got %d\n", r);
r = MsiRecordGetInteger(hrec, 2);
todo_wine ok(r == 2, "Expected 2, got %d\n", r);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
r = MsiViewFetch(hview, &hrec);
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
r = MsiViewClose(hview);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiCloseHandle(hview);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
/* assign to view, primary key matches */
query = "SELECT * FROM `table`";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
hrec = MsiCreateRecord(2);
ok(hrec != 0, "MsiCreateRecord failed\n");
r = MsiRecordSetInteger(hrec, 1, 1);
ok(r == ERROR_SUCCESS, "failed to set integer\n");
r = MsiRecordSetInteger(hrec, 2, 4);
ok(r == ERROR_SUCCESS, "failed to set integer\n");
r = MsiViewModify(hview, MSIMODIFY_ASSIGN, hrec);
todo_wine ok(r == ERROR_SUCCESS, "MsiViewModify failed: %d\n", r);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
r = MsiViewClose(hview);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiCloseHandle(hview);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
query = "SELECT * FROM `table`";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
r = MsiViewFetch(hview, &hrec);
todo_wine ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
r = MsiRecordGetInteger(hrec, 1);
todo_wine ok(r == 1, "Expected 1, got %d\n", r);
r = MsiRecordGetInteger(hrec, 2);
todo_wine ok(r == 4, "Expected 4, got %d\n", r);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
r = MsiViewFetch(hview, &hrec);
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
r = MsiViewClose(hview);
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
r = MsiCloseHandle(hview);
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
/* close database */
r = MsiCloseHandle( hdb );
ok(r == ERROR_SUCCESS, "MsiOpenDatabase close failed\n");
}
static const WCHAR data10[] = { /* MOO */
0x8001, 0x000b,
};
@ -8099,6 +8220,7 @@ START_TEST(db)
test_tables_order();
test_select_markers();
test_viewmodify_update();
test_viewmodify_assign();
test_stringtable();
test_viewmodify_delete();
test_defaultdatabase();