Skip to content

Commit

Permalink
[Code] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BAndysc committed Sep 28, 2021
1 parent f9afb4c commit 6d58dc4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions WDE.SqlQueryGenerator.Test/ExtensionUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ public void TestDefineVariableVariable()
[Test]
public void TestBlankLine()
{
Assert.AreEqual("\n", Queries.BeginTransaction().BlankLine().QueryString);
var trans = Queries.BeginTransaction();
trans.BlankLine();
trans.BlankLine();
Assert.AreEqual("\n", trans.Close().QueryString);
}

[Test]
public void TestQueryToString()
{
Assert.AreEqual("\n", Queries.BeginTransaction().BlankLine().ToString());
Assert.AreEqual("", Queries.BeginTransaction().BlankLine().ToString());
}
}
}
4 changes: 2 additions & 2 deletions WDE.SqlQueryGenerator.Test/InsertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void TestInsertTwoSimpleObjects()
var query = Queries
.Table("a")
.BulkInsert(new []{new { b = 1 }, new { b = 2 }});
Assert.AreEqual($"INSERT INTO `a` (`b`) VALUES{Environment.NewLine}(1),\n(2);", query.QueryString);
Assert.AreEqual($"INSERT INTO `a` (`b`) VALUES{Environment.NewLine}(1),{Environment.NewLine}(2);", query.QueryString);
}

[Test]
Expand All @@ -39,7 +39,7 @@ public void TestInsertTwoSimpleDictionary()
var query = Queries
.Table("a")
.BulkInsert(new []{new Dictionary<string, object?>(){ {"b", 1} }, new Dictionary<string, object?>(){ {"b", 2} }});
Assert.AreEqual($"INSERT INTO `a` (`b`) VALUES{Environment.NewLine}(1),\n(2);", query.QueryString);
Assert.AreEqual($"INSERT INTO `a` (`b`) VALUES{Environment.NewLine}(1),{Environment.NewLine}(2);", query.QueryString);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion WDE.SqlQueryGenerator.Test/QueriesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TestTransaction()
var query = Queries.BeginTransaction();
query.Table("abc").Where(r => true).Delete();
query.Table("def").Where(r => true).Delete();
Assert.AreEqual("DELETE FROM `abc`;\nDELETE FROM `def`;", query.Close().QueryString);
Assert.AreEqual("DELETE FROM `abc`;{Environment.NewLine}DELETE FROM `def`;", query.Close().QueryString);
}
}
}
2 changes: 1 addition & 1 deletion WDE.SqlQueryGenerator/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static IQuery BulkInsert(this ITable table, IEnumerable<Dictionary<string
if (first)
return new Query(table, "");

sb.Append(string.Join(",\n", lines));
sb.Append(string.Join("," + Environment.NewLine, lines));
sb.Append(';');
return new Query(table, sb.ToString());
}
Expand Down
3 changes: 2 additions & 1 deletion WDE.SqlQueryGenerator/MultiQuery.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand All @@ -24,7 +25,7 @@ public void Add(IQuery query)

public IQuery Close()
{
return new Query(new DummyMultiQuery(), string.Join("\n", queries.Select(q => q.QueryString)));
return new Query(new DummyMultiQuery(), string.Join(Environment.NewLine, queries.Select(q => q.QueryString)));
}
}

Expand Down

0 comments on commit 6d58dc4

Please sign in to comment.