forked from sqlkata/querybuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
129 additions
and
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Argon.QueryBuilder.Tests; | ||
|
||
namespace Argon.QueryBuilder.MySql.Tests; | ||
|
||
public class AggregateTest : AggregateTestBase | ||
{ | ||
public override void Average() | ||
{ | ||
base.Average(); | ||
|
||
AssertSql("SELECT AVG(`TTL`) AS `avg` FROM `A`"); | ||
} | ||
|
||
public override void Count() | ||
{ | ||
base.Count(); | ||
|
||
AssertSql("SELECT COUNT(*) AS `count` FROM `A`"); | ||
} | ||
|
||
public override void CountMultipleColumns() | ||
{ | ||
base.CountMultipleColumns(); | ||
|
||
AssertSql("SELECT COUNT(*) AS `count` FROM (SELECT 1 FROM `A` WHERE `ColumnA` IS NOT NULL AND `ColumnB` IS NOT NULL) AS `countQuery`"); | ||
} | ||
|
||
public override void DistinctCount() | ||
{ | ||
base.DistinctCount(); | ||
|
||
AssertSql("SELECT COUNT(*) AS `count` FROM (SELECT DISTINCT * FROM `A`) AS `countQuery`"); | ||
} | ||
|
||
public override void DistinctCountMultipleColumns() | ||
{ | ||
base.DistinctCountMultipleColumns(); | ||
|
||
AssertSql("SELECT COUNT(*) AS `count` FROM (SELECT DISTINCT `ColumnA`, `ColumnB` FROM `A`) AS `countQuery`"); | ||
} | ||
|
||
public override void Max() | ||
{ | ||
base.Max(); | ||
|
||
AssertSql("SELECT MAX(`LatencyMs`) AS `max` FROM `A`"); | ||
} | ||
|
||
public override void Min() | ||
{ | ||
base.Min(); | ||
|
||
AssertSql("SELECT MIN(`LatencyMs`) AS `min` FROM `A`"); | ||
} | ||
|
||
public override void Sum() | ||
{ | ||
base.Sum(); | ||
|
||
AssertSql("SELECT SUM(`PacketsDropped`) AS `sum` FROM `A`"); | ||
} | ||
} |
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,38 @@ | ||
using Xunit; | ||
|
||
namespace Argon.QueryBuilder.Tests; | ||
|
||
public class AggregateTestBase : TestBase | ||
{ | ||
[Fact] | ||
public virtual void Count() | ||
=> AssertQuery(new Query("A").AsCount()); | ||
|
||
[Fact] | ||
public virtual void CountMultipleColumns() | ||
=> AssertQuery(new Query("A").AsCount(new[] { "ColumnA", "ColumnB" })); | ||
|
||
[Fact] | ||
public virtual void DistinctCount() | ||
=> AssertQuery(new Query("A").Distinct().AsCount()); | ||
|
||
[Fact] | ||
public virtual void DistinctCountMultipleColumns() | ||
=> AssertQuery(new Query("A").Distinct().AsCount(new[] { "ColumnA", "ColumnB" })); | ||
|
||
[Fact] | ||
public virtual void Average() | ||
=> AssertQuery(new Query("A").AsAverage("TTL")); | ||
|
||
[Fact] | ||
public virtual void Sum() | ||
=> AssertQuery(new Query("A").AsSum("PacketsDropped")); | ||
|
||
[Fact] | ||
public virtual void Max() | ||
=> AssertQuery(new Query("A").AsMax("LatencyMs")); | ||
|
||
[Fact] | ||
public virtual void Min() | ||
=> AssertQuery(new Query("A").AsMin("LatencyMs")); | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.