public void WhenOneStatement_ThenReturnString() { var filter = Filter.When("Name", QueryComparison.Equal, "John").Build(); var result = FilterConverter.ToTableQueryFilter(filter); Assert.That(result, Is.EqualTo("Name eq 'John'")); }
/// <summary> /// Query the table using a filter. /// </summary> /// <param name="filter">Filter to apply in the query.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation. Result will contain list of matching entities.</returns> /// <exception cref="T:System.ArgumentNullException"><paramref name="filter" /> is null.</exception> public Task <IList <TEntity> > QueryAsync(Filter filter, CancellationToken cancellationToken = default) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } var filterString = FilterConverter.ToTableQueryFilter(filter); return(_table.QueryAsync <TEntity>(filterString, cancellationToken)); }
public void WhenTwoStatementsWithOrOp_ThenReturnString() { var filter = Filter .When("Name", QueryComparison.Equal, "John") .Or() .When("Age", QueryComparison.Equal, "50") .Build(); var result = FilterConverter.ToTableQueryFilter(filter); Assert.That(result, Is.EqualTo("(Name eq 'John') or (Age eq '50')")); }
public void WhenTwoStatementsWithAndTwoOps_ThenReturnString() { var filter = Filter .When("Name", QueryComparison.Equal, "John") .And() .When("Age", QueryComparison.Equal, "50") .And() .When("Address", QueryComparison.NotEqual, "Malaysia") .Build(); var result = FilterConverter.ToTableQueryFilter(filter); Assert.That(result, Is.EqualTo("((Name eq 'John') and (Age eq '50')) and (Address ne 'Malaysia')")); }
public void WhenIsNull_ThenReturnEmpty() { var result = FilterConverter.ToTableQueryFilter(null); Assert.That(result, Is.Empty); }