Skip to content

Commit

Permalink
test(WhereConditionBaseExtensions): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seangwright committed Jan 2, 2022
1 parent 8436b0c commit cd0ddf5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ public void QueryDatabase(ILogger logger)
}
```

```csharp
var query = DocumentHelper.GetDocuments()
.Where(w => w.WhereInPath("path1", "path2"));
```

### ObjectQuery

#### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,61 @@ public void MultiDocumentQuery_If_Will_Execute_The_ElseAction_If_The_Condition_I
action.ReceivedCalls().Should().BeEmpty();
elseAction.ReceivedCalls().Should().HaveCount(1);
}

[Test]
public void WhereCondition_WhereInPath_Will_Combine_Paths_With_An_Or()
{
var sut = new DocumentQuery();

var result = sut.Where(w => w.WhereInPath("path1", "path2"));

result.WhereCondition.Should().Be("([NodeAliasPath] = @NodeAliasPath OR [NodeAliasPath] = @NodeAliasPath1)");
result.Parameters.Should().HaveCount(2);

var param1 = result.Parameters[0];
var param2 = result.Parameters[1];

param1.Name.Should().Be("@NodeAliasPath");
param1.Value.Should().Be("path1");

param2.Name.Should().Be("@NodeAliasPath1");
param2.Value.Should().Be("path2");
}

[Test]
public void WhereCondition_WhereInPath_PathType_Children_Will_Combine_Paths_With_An_Or()
{
var sut = new DocumentQuery();

var result = sut.Where(w => w.WhereInPath("path1", PathTypeEnum.Children));

result.WhereCondition.Should().Be("[NodeAliasPath] LIKE @NodeAliasPath");
result.Parameters.Should().HaveCount(1);

var param1 = result.Parameters[0];

param1.Name.Should().Be("@NodeAliasPath");
param1.Value.Should().Be("path1/%");
}

[Test]
public void WhereCondition_WhereInPath_PathType_Section_Will_Combine_Paths_With_An_Or()
{
var sut = new DocumentQuery();

var result = sut.Where(w => w.WhereInPath("path1", PathTypeEnum.Section));

result.WhereCondition.Should().Be("([NodeAliasPath] LIKE @NodeAliasPath OR [NodeAliasPath] = @NodeAliasPath1)");
result.Parameters.Should().HaveCount(2);

var param1 = result.Parameters[0];
var param2 = result.Parameters[1];

param1.Name.Should().Be("@NodeAliasPath");
param1.Value.Should().Be("path1/%");

param2.Name.Should().Be("@NodeAliasPath1");
param2.Value.Should().Be("/path1");
}
}
}

0 comments on commit cd0ddf5

Please sign in to comment.