-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4714 from berkarslan-xo/bugfix/Issue-4673
Issue-4673 - SQL Console raises error for variable declarations with "@" character
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
DNN Platform/Tests/DotNetNuke.Tests.Data/PetaPocoExtTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace DotNetNuke.Tests.Data | ||
{ | ||
using System.Reflection; | ||
using DotNetNuke.Data.PetaPoco; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class PetaPocoExtTests | ||
{ | ||
[TestCase(null, null, null)] | ||
[TestCase(null, new object[0], null)] | ||
[TestCase(null, new object[] { "" }, null)] | ||
[TestCase("", null, "")] | ||
[TestCase("", new object[0], "")] | ||
[TestCase("", new object[] { "" }, "")] | ||
[TestCase( | ||
"declare @test varchar(20) = 'test@test.com'\nselect @test", | ||
null, | ||
"declare @@test varchar(20) = 'test@@test.com'\nselect @@test")] | ||
[TestCase( | ||
"declare @test varchar(20) = 'test@test.com'\nselect @test", | ||
new object[0], | ||
"declare @@test varchar(20) = 'test@@test.com'\nselect @@test")] | ||
[TestCase( | ||
"declare @test varchar(20) = 'test@test.com'\nselect @test", | ||
new object[] { "" }, | ||
"declare @test varchar(20) = 'test@test.com'\nselect @test")] | ||
public void NormalizeSql_WithAtCharAndEmptyArguments_EscapesAtCharSuccessfully( | ||
string sql, | ||
object[] args, | ||
string expected) | ||
{ | ||
// Arrange | ||
const string NormalizeSqlMethodName = "NormalizeSql"; | ||
var normalizeSqlMethod = typeof(PetaPocoExt) | ||
.GetMethod( | ||
NormalizeSqlMethodName, | ||
BindingFlags.Static | BindingFlags.NonPublic); | ||
|
||
// Act | ||
var result = normalizeSqlMethod.Invoke( | ||
null, | ||
new object[] | ||
{ | ||
sql, | ||
args | ||
}); | ||
|
||
// Assert | ||
Assert.AreEqual(expected, result); | ||
} | ||
} | ||
} |