Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kccarter76 committed Jun 29, 2020
1 parent 9a1c79d commit c42f738
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.AspNet.OData.Builder;
using Microsoft.AspNet.OData.Extensions;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNet.OData.Interfaces;
using Microsoft.AspNet.OData.Test.Abstraction;
using Microsoft.AspNet.OData.Test.Builder.TestModels;
using Microsoft.AspNet.OData.Test.Common;
Expand All @@ -39,6 +40,7 @@
using Microsoft.AspNet.OData.Builder;
using Microsoft.AspNet.OData.Extensions;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNet.OData.Interfaces;
using Microsoft.AspNet.OData.Test.Abstraction;
using Microsoft.AspNet.OData.Test.Builder.TestModels;
using Microsoft.AspNet.OData.Test.Common;
Expand Down Expand Up @@ -249,7 +251,7 @@ public void CanExtractQueryOptionsCorrectly()
);

// Act
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);

// Assert
Assert.Equal("Filter", queryOptions.RawValues.Filter);
Expand Down Expand Up @@ -285,7 +287,7 @@ public void CanExtractQueryOptionsWithExtraSpacesCorrectly(string clause)
);

// Act
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);

// Assert
Assert.Equal("Filter", queryOptions.RawValues.Filter);
Expand Down Expand Up @@ -315,7 +317,7 @@ public void ApplyTo_Throws_With_Null_Queryable()
"http://server/service/Customers/?$filter=Filter&$select=Select&$orderby=OrderBy&$expand=Expand&$top=10&$skip=20&$count=true&$skiptoken=SkipToken&$deltatoken=DeltaToken"
);

var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);

// Act & Assert
ExceptionAssert.ThrowsArgumentNull(() => queryOptions.ApplyTo(null), "query");
Expand All @@ -332,7 +334,7 @@ public void ApplyTo_With_QuerySettings_Throws_With_Null_Queryable()
"http://server/service/Customers/?$filter=Filter&$select=Select&$orderby=OrderBy&$expand=Expand&$top=10&$skip=20&$count=true&$skiptoken=SkipToken&$deltatoken=DeltaToken"
);

var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);

// Act & Assert
ExceptionAssert.ThrowsArgumentNull(() => queryOptions.ApplyTo(null, new ODataQuerySettings()), "query");
Expand All @@ -349,7 +351,7 @@ public void ApplyTo_Throws_With_Null_QuerySettings()
"http://server/service/Customers/?$filter=Filter&$select=Select&$orderby=OrderBy&$expand=Expand&$top=10&$skip=20&$count=true&$skiptoken=SkipToken&$deltatoken=DeltaToken"
);

var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);

// Act & Assert
ExceptionAssert.ThrowsArgumentNull(() => queryOptions.ApplyTo(new Customer[0].AsQueryable(), null), "querySettings");
Expand All @@ -368,7 +370,8 @@ public void ApplyTo_Adds_Missing_Keys_To_OrderBy(string oDataQuery, bool ensureS
"http://server/service/Customers?" + oDataQuery
);

var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);

ODataQuerySettings querySettings = new ODataQuerySettings
{
EnsureStableOrdering = ensureStableOrdering,
Expand Down Expand Up @@ -397,7 +400,8 @@ public void ApplyTo_Adds_Missing_NonKey_Properties_To_OrderBy(string oDataQuery,
"http://server/service/Customers?" + oDataQuery
);

var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);

ODataQuerySettings querySettings = new ODataQuerySettings
{
EnsureStableOrdering = ensureStableOrdering
Expand Down Expand Up @@ -426,7 +430,7 @@ public void ApplyTo_Does_Not_Replace_Original_OrderBy_With_Missing_Keys()
);

// Act
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
OrderByQueryOption originalOption = queryOptions.OrderBy;
ODataQuerySettings querySettings = new ODataQuerySettings();

Expand Down Expand Up @@ -463,7 +467,7 @@ public void ContextPropertyGetter()
HttpMethod.Get,
"http://server/service/Customers"
);
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
var entityType = queryOptions.Context.ElementClrType;
Assert.NotNull(entityType);
Assert.Equal(typeof(Customer).FullName, entityType.Namespace + "." + entityType.Name);
Expand Down Expand Up @@ -498,7 +502,7 @@ public void QueryTest(string queryName, string queryValue)
}
else
{
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);

if (queryName == "$filter")
{
Expand Down Expand Up @@ -534,7 +538,7 @@ public void MissingQueryReturnsOriginalList()
var message = RequestFactory.Create(HttpMethod.Get, uri);

// Act
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), message);

// Assert: everything is null
Assert.Null(queryOptions.RawValues.OrderBy);
Expand Down Expand Up @@ -1173,7 +1177,7 @@ public void DuplicateUnsupportedQueryParametersIgnored()
request.EnableHttpDependencyInjectionSupport();
#endif
// Act
var queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
IODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);

// Assert
Assert.Equal("10", queryOptions.RawValues.Top);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Net.Http.Headers;
using Microsoft.AspNet.OData.Builder;
using Microsoft.AspNet.OData.Formatter;
using Microsoft.AspNet.OData.Interfaces;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNet.OData.Test.Abstraction;
using Microsoft.AspNet.OData.Test.Common;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void Ctor_SuccedsIfEntityTypesMatch()

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
Assert.Equal("10", query.Top.RawValue);
}

Expand Down Expand Up @@ -100,7 +101,7 @@ public void GetIfMatchOrNoneMatch_ReturnsETag_SetETagHeaderValue(string header)
ODataQueryContext context = new ODataQueryContext(model, typeof(Customer));

// Act
ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
ETag result = header.Equals("IfMatch") ? query.IfMatch : query.IfNoneMatch;
dynamic dynamicResult = result;

Expand All @@ -124,7 +125,7 @@ public void GetIfMatchOrNoneMatch_ETagIsNull_IfETagHeaderValueNotSet(string head
ODataQueryContext context = new ODataQueryContext(model, typeof(Customer));

// Act
ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
ETag result = header.Equals("IfMatch") ? query.IfMatch : query.IfNoneMatch;

// Assert
Expand All @@ -141,7 +142,7 @@ public void ApplyTo_ThrowsArgument_If_QueryTypeDoesnotMatch()

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);

ExceptionAssert.ThrowsArgument(
() => query.ApplyTo(Enumerable.Empty<int>().AsQueryable()),
Expand All @@ -159,7 +160,7 @@ public void ApplyTo_Succeeds_If_QueryTypeDerivesFromOptionsType()

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);

ExceptionAssert.DoesNotThrow(
() => query.ApplyTo(Enumerable.Empty<KirklandCustomer>().AsQueryable()));
Expand All @@ -175,7 +176,7 @@ public void ApplyTo_Succeeds_If_QueryTypeMatchesOptionsType()

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);

ExceptionAssert.DoesNotThrow(
() => query.ApplyTo(Enumerable.Empty<Customer>().AsQueryable()));
Expand All @@ -191,7 +192,7 @@ public void ApplyTo_WithQuerySettings_ThrowsArgument_If_QueryTypeDoesnotMatch()

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);

ExceptionAssert.ThrowsArgument(
() => query.ApplyTo(Enumerable.Empty<int>().AsQueryable(), new ODataQuerySettings()),
Expand All @@ -209,7 +210,7 @@ public void ApplyTo_WithQuerySettings_Succeeds_If_QueryTypeDerivesFromOptionsTyp

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);

ExceptionAssert.DoesNotThrow(
() => query.ApplyTo(Enumerable.Empty<KirklandCustomer>().AsQueryable(), new ODataQuerySettings()));
Expand All @@ -225,7 +226,7 @@ public void ApplyTo_WithQuerySettings_Succeeds_If_QueryTypeMatchesOptionsType()

ODataQueryContext context = new ODataQueryContext(builder.GetEdmModel(), typeof(Customer));

ODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);
IODataQueryOptions<Customer> query = new ODataQueryOptions<Customer>(context, request);

ExceptionAssert.DoesNotThrow(
() => query.ApplyTo(Enumerable.Empty<Customer>().AsQueryable(), new ODataQuerySettings()));
Expand Down

0 comments on commit c42f738

Please sign in to comment.