Skip to content

Commit

Permalink
Added smoke tests to prove that null binary results are returned as null
Browse files Browse the repository at this point in the history
  • Loading branch information
abe545 committed Feb 14, 2017
1 parent be25106 commit ee3475d
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
70 changes: 70 additions & 0 deletions SmokeTests/DynamicSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,26 @@ Tuple<bool, string> ExecuteBinarySync(IDbConnection db)
return Tuple.Create(true, "");
}

[SmokeTest("Dynamic Syntax Empty Binary ResultSet")]
Tuple<bool, string> ExecutEmptyBinarySync(IDbConnection db)
{
byte[] res = db.Execute(Program.timeout).usp_GetEmptyBinary(@includeResults: false);
if (res != null)
return Tuple.Create(false, "The stored procedure returned an empty result set, so should not have a value");

return Tuple.Create(true, "");
}

[SmokeTest("Dynamic Syntax NULL Binary ResultSet")]
Tuple<bool, string> ExecutNullBinarySync(IDbConnection db)
{
byte[] res = db.Execute(Program.timeout).usp_GetEmptyBinary(@includeResults: true);
if (res != null)
return Tuple.Create(false, "The stored procedure returned an empty result set, so should not have a value");

return Tuple.Create(true, "");
}

[SmokeTest("Dynamic Syntax Binary ResultSet (await)")]
async Task<Tuple<bool, string>> ExecuteBinaryAsync(IDbConnection db)
{
Expand All @@ -717,6 +737,26 @@ async Task<Tuple<bool, string>> ExecuteBinaryAsync(IDbConnection db)
return Tuple.Create(true, "");
}

[SmokeTest("Dynamic Syntax Empty Binary ResultSet (await)")]
async Task<Tuple<bool, string>> ExecutEmptyBinaryAsync(IDbConnection db)
{
byte[] res = await db.ExecuteAsync(Program.timeout).usp_GetEmptyBinary(@includeResults: false);
if (res != null)
return Tuple.Create(false, "The stored procedure returned an empty result set, so should not have a value");

return Tuple.Create(true, "");
}

[SmokeTest("Dynamic Syntax NULL Binary ResultSet (await)")]
async Task<Tuple<bool, string>> ExecutNullBinaryAsync(IDbConnection db)
{
byte[] res = await db.ExecuteAsync(Program.timeout).usp_GetEmptyBinary(@includeResults: true);
if (res != null)
return Tuple.Create(false, "The stored procedure returned an empty result set, so should not have a value");

return Tuple.Create(true, "");
}

[SmokeTest("Dynamic Syntax Binary ResultSet (task)")]
Task<Tuple<bool, string>> ExecuteBinaryTask(IDbConnection db)
{
Expand All @@ -737,6 +777,36 @@ Task<Tuple<bool, string>> ExecuteBinaryTask(IDbConnection db)
});
}

[SmokeTest("Dynamic Syntax Empty Binary ResultSet (task)")]
Task<Tuple<bool, string>> ExecutEmptyBinaryTask(IDbConnection db)
{
Task<byte[]> t = db.ExecuteAsync(Program.timeout).usp_GetEmptyBinary(@includeResults: false);

return t.ContinueWith(r =>
{
var res = t.Result;
if (res != null)
return Tuple.Create(false, "The stored procedure returned an empty result set, so should not have a value");

return Tuple.Create(true, "");
});
}

[SmokeTest("Dynamic Syntax NULL Binary ResultSet (task)")]
Task<Tuple<bool, string>> ExecutNullBinaryTask(IDbConnection db)
{
Task<byte[]> t = db.ExecuteAsync(Program.timeout).usp_GetEmptyBinary(@includeResults: true);

return t.ContinueWith(r =>
{
var res = t.Result;
if (res != null)
return Tuple.Create(false, "The stored procedure returned an empty result set, so should not have a value");

return Tuple.Create(true, "");
});
}

[SmokeTest("Dynamic Syntax Binary Parameter")]
Tuple<bool, string> ExecuteBinaryParameter(IDbConnection db)
{
Expand Down
98 changes: 98 additions & 0 deletions SmokeTests/FluentSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,36 @@ Tuple<bool, string> ExecuteBinarySync(IDbConnection db)
return Tuple.Create(true, "");
}

[SmokeTest("Fluent Syntax Empty Binary ResultSet")]
Tuple<bool, string> ExecuteEmptyBinarySync(IDbConnection db)
{
byte[] res = StoredProcedure.Create("usp_GetEmptyBinary")
.WithParameter("includeResults", false)
.WithResults<byte[]>()
.Execute(db, Program.timeout)
.SingleOrDefault();

if (res != null)
return Tuple.Create(false, "The bytes returned from the stored procedure were not null");

return Tuple.Create(true, "");
}

[SmokeTest("Fluent Syntax NULL Binary ResultSet")]
Tuple<bool, string> ExecuteNullBinarySync(IDbConnection db)
{
byte[] res = StoredProcedure.Create("usp_GetEmptyBinary")
.WithParameter("includeResults", true)
.WithResults<byte[]>()
.Execute(db, Program.timeout)
.Single();

if (res != null)
return Tuple.Create(false, "The bytes returned from the stored procedure were not null");

return Tuple.Create(true, "");
}

[SmokeTest("Fluent Syntax Binary ResultSet (await)")]
async Task<Tuple<bool, string>> ExecuteBinaryAsync(IDbConnection db)
{
Expand All @@ -994,6 +1024,36 @@ async Task<Tuple<bool, string>> ExecuteBinaryAsync(IDbConnection db)
return Tuple.Create(true, "");
}

[SmokeTest("Fluent Syntax Empty Binary ResultSet (await)")]
async Task<Tuple<bool, string>> ExecuteEmptyBinaryAsync(IDbConnection db)
{
byte[] res = (await StoredProcedure.Create("usp_GetEmptyBinary")
.WithParameter("includeResults", false)
.WithResults<byte[]>()
.ExecuteAsync(db, Program.timeout))
.SingleOrDefault();

if (res != null)
return Tuple.Create(false, "The bytes returned from the stored procedure were not null");

return Tuple.Create(true, "");
}

[SmokeTest("Fluent Syntax NULL Binary ResultSet (await)")]
async Task<Tuple<bool, string>> ExecuteNullBinaryAsync(IDbConnection db)
{
byte[] res = (await StoredProcedure.Create("usp_GetEmptyBinary")
.WithParameter("includeResults", true)
.WithResults<byte[]>()
.ExecuteAsync(db, Program.timeout))
.Single();

if (res != null)
return Tuple.Create(false, "The bytes returned from the stored procedure were not null");

return Tuple.Create(true, "");
}

[SmokeTest("Fluent Syntax Binary ResultSet (task)")]
Task<Tuple<bool, string>> ExecuteBinaryTask(IDbConnection db)
{
Expand All @@ -1017,6 +1077,44 @@ Task<Tuple<bool, string>> ExecuteBinaryTask(IDbConnection db)
});
}

[SmokeTest("Fluent Syntax Empty Binary ResultSet (task)")]
Task<Tuple<bool, string>> ExecuteEmptyBinaryTask(IDbConnection db)
{
var t = StoredProcedure.Create("usp_GetEmptyBinary")
.WithParameter("includeResults", false)
.WithResults<byte[]>()
.ExecuteAsync(db, Program.timeout);

return t.ContinueWith(r =>
{
var res = r.Result.SingleOrDefault();

if (res != null)
return Tuple.Create(false, "The bytes returned from the stored procedure were not null");

return Tuple.Create(true, "");
});
}

[SmokeTest("Fluent Syntax NULL Binary ResultSet")]
Task<Tuple<bool, string>> ExecuteNullBinaryTask(IDbConnection db)
{
var t = StoredProcedure.Create("usp_GetEmptyBinary")
.WithParameter("includeResults", true)
.WithResults<byte[]>()
.ExecuteAsync(db, Program.timeout);

return t.ContinueWith(r =>
{
var res = r.Result.Single();

if (res != null)
return Tuple.Create(false, "The bytes returned from the stored procedure were not null");

return Tuple.Create(true, "");
});
}

[SmokeTest("Fluent Syntax Binary Parameter")]
Tuple<bool, string> ExecuteBinaryParameter(IDbConnection db)
{
Expand Down
Binary file modified SmokeTests/Smoke.mdf
Binary file not shown.
Binary file modified SmokeTests/Smoke_log.ldf
Binary file not shown.

0 comments on commit ee3475d

Please sign in to comment.