Skip to content

Commit

Permalink
Move AstNodes to FluentSQL.Compilation.Parser.Nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
weelink committed Jul 25, 2019
1 parent e699f18 commit 44cc1e2
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 14 deletions.
@@ -1,7 +1,7 @@
using System;

using FluentSQL.Compilation;
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;

namespace FluentSQL.Tests.Compilation.Builders
{
Expand Down
Expand Up @@ -4,7 +4,7 @@
using FluentAssertions.Execution;
using FluentAssertions.Primitives;

using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;

namespace FluentSQL.Tests.Compilation.Parser.Assertions
{
Expand Down
Expand Up @@ -2,7 +2,7 @@
using FluentAssertions.Execution;
using FluentAssertions.Primitives;

using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;

namespace FluentSQL.Tests.Compilation.Parser.Assertions
{
Expand All @@ -28,5 +28,16 @@ public AndConstraint<FromNodeAssertions> HaveAlias(string alias, string because

return new AndConstraint<FromNodeAssertions>(this);
}

public AndConstraint<FromNodeAssertions> NotHaveAnAlias(string because = "", params object[] becauseArgs)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.Given(() => Subject.Alias)
.ForCondition(x => x == null)
.FailWith("Expected {context:FromNode} to not have an alias, but it had {0}", x => x);

return new AndConstraint<FromNodeAssertions>(this);
}
}
}
@@ -1,4 +1,4 @@
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Tests.Compilation.Parser.Assertions;

namespace FluentSQL.Tests.Compilation.Parser.Extensions
Expand Down
@@ -1,4 +1,4 @@
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Tests.Compilation.Parser.Assertions;

namespace FluentSQL.Tests.Compilation.Parser.Extensions
Expand Down
Expand Up @@ -3,10 +3,12 @@
using FluentAssertions;

using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;
using FluentSQL.Querying.Statements.Extensions;
using FluentSQL.Tests.Builders;
using FluentSQL.Tests.Compilation.Parser.Builders;
using FluentSQL.Tests.Compilation.Parser.Extensions;
using FluentSQL.Tests.Examples;
using FluentSQL.Tests.Examples.Builders;

Expand Down Expand Up @@ -47,7 +49,7 @@ public void It_should_add_the_from_clause()
[Fact]
public void It_should_have_no_alias()
{
RootNode.ChildNodes.OfType<FromNode>().Single().Alias.Should().BeNull();
RootNode.ChildNodes.OfType<FromNode>().Single().Should().NotHaveAnAlias();
}
}

Expand Down Expand Up @@ -85,7 +87,7 @@ public void It_should_add_the_from_clause()
[Fact]
public void It_should_have_the_alias()
{
RootNode.ChildNodes.OfType<FromNode>().Single().Alias.Should().Be(Alias);
RootNode.ChildNodes.OfType<FromNode>().Single().Should().HaveAlias(Alias);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/FluentSQL.Tests/Compilation/Parser/QueryParserTests.cs
@@ -1,4 +1,5 @@
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;
using FluentSQL.Tests.Compilation.Parser.Builders;
using FluentSQL.Tests.Compilation.Parser.Extensions;
Expand Down
@@ -1,6 +1,7 @@
using FluentAssertions;

using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;
using FluentSQL.Querying.Statements.Extensions;
using FluentSQL.Tests.Builders;
Expand Down
@@ -1,6 +1,7 @@
using FluentAssertions;

using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;
using FluentSQL.Querying.Statements.Extensions;
using FluentSQL.Tests.Builders;
Expand Down
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace FluentSQL.Compilation.Parser
namespace FluentSQL.Compilation.Parser.Nodes
{
public class AstNode
{
Expand Down
@@ -1,4 +1,4 @@
namespace FluentSQL.Compilation.Parser
namespace FluentSQL.Compilation.Parser.Nodes
{
public sealed class FromNode : AstNode
{
Expand Down
@@ -1,4 +1,4 @@
namespace FluentSQL.Compilation.Parser
namespace FluentSQL.Compilation.Parser.Nodes
{
public sealed class UnionAllNode : AstNode
{
Expand Down
@@ -1,4 +1,4 @@
namespace FluentSQL.Compilation.Parser
namespace FluentSQL.Compilation.Parser.Nodes
{
public sealed class UnionNode : AstNode
{
Expand Down
4 changes: 3 additions & 1 deletion src/FluentSQL/Compilation/Parser/QueryParser.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq.Expressions;

using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;
using FluentSQL.Querying.Statements;

Expand Down Expand Up @@ -112,7 +113,8 @@ internal void Select<TSqlExpression>(Expression<Func<TSqlExpression>> expression
}

private (AstNode firstResult, AstNode secondResult) ParseMultiple<TFirstParameters, TSecondParameters, TQueryResult>(
QueryComponent<TFirstParameters, TQueryResult> first, QueryComponent<TSecondParameters, TQueryResult> second)
QueryComponent<TFirstParameters, TQueryResult> first,
QueryComponent<TSecondParameters, TQueryResult> second)
{
var firstParser = new QueryParser();
AstNode firstResult = firstParser.Parse(first.QueryContext);
Expand Down
2 changes: 1 addition & 1 deletion src/FluentSQL/Compilation/QueryCompiler.cs
@@ -1,4 +1,4 @@
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;

namespace FluentSQL.Compilation
Expand Down
1 change: 1 addition & 0 deletions src/FluentSQL/Databases/Database.cs
@@ -1,5 +1,6 @@
using FluentSQL.Compilation;
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;

namespace FluentSQL.Databases
Expand Down
@@ -1,5 +1,5 @@
using FluentSQL.Compilation;
using FluentSQL.Compilation.Parser;
using FluentSQL.Compilation.Parser.Nodes;
using FluentSQL.Querying;

namespace FluentSQL.Databases.SqlServer
Expand Down

0 comments on commit 44cc1e2

Please sign in to comment.