Skip to content

Commit 027dcc2

Browse files
committed
Rewrite fixture setup code as one long SQL statement.
1 parent 5cebda1 commit 027dcc2

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

tests/SideBySide/StoredProcedureFixture.cs

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,26 @@ name VARCHAR(63)
1313
) RETURNS VARCHAR(63)
1414
BEGIN
1515
RETURN name;
16-
END");
17-
Connection.Execute(@"DROP FUNCTION IF EXISTS failing_function;
16+
END;
17+
18+
DROP FUNCTION IF EXISTS failing_function;
1819
CREATE FUNCTION failing_function()
1920
RETURNS INT
2021
BEGIN
2122
DECLARE v1 INT;
2223
SELECT c1 FROM table_that_does_not_exist INTO v1;
2324
RETURN v1;
24-
END");
25-
Connection.Execute(@"DROP PROCEDURE IF EXISTS echop;
25+
END;
26+
27+
DROP PROCEDURE IF EXISTS echop;
2628
CREATE PROCEDURE echop(
2729
IN name VARCHAR(63)
2830
)
2931
BEGIN
3032
SELECT name;
31-
END");
32-
Connection.Execute(@"DROP PROCEDURE IF EXISTS circle;
33+
END;
34+
35+
DROP PROCEDURE IF EXISTS circle;
3336
CREATE PROCEDURE circle(
3437
IN radius DOUBLE,
3538
IN height DOUBLE,
@@ -47,24 +50,27 @@ OUT shape VARCHAR(63)
4750
SELECT area * height INTO volume;
4851
SELECT 'circle' INTO shape;
4952
SELECT CONCAT(name, shape);
50-
END");
51-
Connection.Execute(@"DROP PROCEDURE IF EXISTS out_string;
53+
END;
54+
55+
DROP PROCEDURE IF EXISTS out_string;
5256
CREATE PROCEDURE out_string(
5357
OUT value VARCHAR(100)
5458
)
5559
BEGIN
5660
SELECT 'test value' INTO value;
57-
END");
58-
Connection.Execute(@"DROP PROCEDURE IF EXISTS out_null;
61+
END;
62+
63+
DROP PROCEDURE IF EXISTS out_null;
5964
CREATE PROCEDURE out_null(
6065
OUT string_value VARCHAR(100),
6166
OUT int_value INT
6267
)
6368
BEGIN
6469
SELECT NULL INTO string_value;
6570
SELECT NULL INTO int_value;
66-
END");
67-
Connection.Execute(@"drop table if exists sproc_multiple_rows;
71+
END;
72+
73+
drop table if exists sproc_multiple_rows;
6874
create table sproc_multiple_rows (
6975
value integer not null primary key auto_increment,
7076
name text not null
@@ -77,21 +83,24 @@ insert into sproc_multiple_rows values
7783
(5, 'five'),
7884
(6, 'six'),
7985
(7, 'seven'),
80-
(8, 'eight');");
81-
Connection.Execute(@"drop procedure if exists number_multiples;
86+
(8, 'eight');
87+
88+
drop procedure if exists number_multiples;
8289
create procedure number_multiples (in factor int)
8390
begin
8491
select name from sproc_multiple_rows
8592
where mod(value, factor) = 0
8693
order by name;
87-
end;");
88-
Connection.Execute(@"drop procedure if exists multiple_result_sets;
94+
end;
95+
96+
drop procedure if exists multiple_result_sets;
8997
create procedure multiple_result_sets (in pivot int)
9098
begin
9199
select name from sproc_multiple_rows where value < pivot order by name;
92100
select name from sproc_multiple_rows where value > pivot order by name;
93-
end;");
94-
Connection.Execute(@"drop procedure if exists number_lister;
101+
end;
102+
103+
drop procedure if exists number_lister;
95104
create procedure number_lister (inout high int)
96105
begin
97106
DECLARE i int;
@@ -103,17 +112,19 @@ create procedure number_lister (inout high int)
103112
SET i = i + 1;
104113
END WHILE;
105114
SET high = high + 1;
106-
end;");
107-
Connection.Execute(@"drop procedure if exists `dotted.name`;
115+
end;
116+
117+
drop procedure if exists `dotted.name`;
108118
create procedure `dotted.name`()
109119
begin
110120
select 1, 2, 3;
111-
end;");
112-
Connection.Execute(@"DROP PROCEDURE IF EXISTS `GetTime`;
121+
end;
122+
123+
DROP PROCEDURE IF EXISTS `GetTime`;
113124
CREATE PROCEDURE `GetTime`(OUT OutTime TIME)
114125
BEGIN
115126
SET OutTime = CURTIME();
116-
END");
127+
END;");
117128

118129
if (AppConfig.SupportsJson)
119130
{

0 commit comments

Comments
 (0)