Skip to content

Commit

Permalink
Added a fluent API to get only files or folders results
Browse files Browse the repository at this point in the history
  • Loading branch information
ju2pom committed Sep 20, 2017
1 parent 88a5fbf commit ef3f8f7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
23 changes: 18 additions & 5 deletions EverythingNet.Tests/LogicalQueryTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using EverythingNet.Core;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EverythingNet.Tests
{
Expand Down Expand Up @@ -41,5 +36,23 @@ public void AndQuery()

Assert.That(queryable.ToString(), Is.EqualTo("startwith:prefix size:<=100kb"));
}


[Test]
public void FilesQuery()
{
var filesQuery = this.everything.Search().Files.Name();

Assert.That(filesQuery.ToString(), Is.EqualTo("files:"));
}


[Test]
public void FoldersQuery()
{
var foldersQuery = this.everything.Search().Folders.Name();

Assert.That(foldersQuery.ToString(), Is.EqualTo("folders:"));
}
}
}
4 changes: 4 additions & 0 deletions EverythingNet/Interfaces/IQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ public interface IQuery
{
IQuery Not { get; }

IQuery Files { get; }

IQuery Folders { get; }

INameQueryable Name();

INameQueryable Name(string namePattern);
Expand Down
6 changes: 5 additions & 1 deletion EverythingNet/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using EverythingNet.Interfaces;

using IQueryable = EverythingNet.Interfaces.IQueryable;
using IQueryable = Interfaces.IQueryable;

internal class Query : IQuery, IQueryGenerator
{
Expand All @@ -20,6 +20,10 @@ public Query(IEverythingInternal everything, IQueryGenerator parent = null)

public IQuery Not => new LogicalQuery(this.everything, this, "!");

public IQuery Files => new LogicalQuery(this.everything, this, "files:");

public IQuery Folders => new LogicalQuery(this.everything, this, "folders:");

public virtual IEnumerable<string> GetQueryParts()
{
return this.parent?.GetQueryParts() ?? Enumerable.Empty<string>();
Expand Down

0 comments on commit ef3f8f7

Please sign in to comment.