Skip to content

Commit

Permalink
Change E2E class Fixture to allow parallel running
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhg committed Feb 26, 2020
1 parent ec69a7b commit 8becfbf
Show file tree
Hide file tree
Showing 160 changed files with 874 additions and 1,055 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override void Apply(StructuralTypeConfiguration edmTypeConfiguration, ODa
}
else
{
querySettings.MaxTop = pageAttribute.MaxTop;
querySettings.MaxTop = pageAttribute.MaxTop;
}

if (pageAttribute.PageSize > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public static IRouteBuilder SetDefaultQuerySettings(this IRouteBuilder builder,
throw Error.ArgumentNull("defaultQuerySettings");
}

if (!defaultQuerySettings.MaxTop.HasValue || defaultQuerySettings.MaxTop > 0)
{
ModelBoundQuerySettings.DefaultModelBoundQuerySettings.MaxTop = defaultQuerySettings.MaxTop;
}
//if (!defaultQuerySettings.MaxTop.HasValue || defaultQuerySettings.MaxTop > 0)
//{
// ModelBoundQuerySettings.DefaultModelBoundQuerySettings.MaxTop = defaultQuerySettings.MaxTop;
//}

DefaultQuerySettings querySettings = builder.ServiceProvider.GetRequiredService<DefaultQuerySettings>();
if (querySettings == null)
Expand Down Expand Up @@ -91,10 +91,6 @@ public static IRouteBuilder MaxTop(this IRouteBuilder builder, int? maxTopValue)

DefaultQuerySettings defaultQuerySettings = builder.GetDefaultQuerySettings();
defaultQuerySettings.MaxTop = maxTopValue;
if (!maxTopValue.HasValue || maxTopValue > 0)
{
ModelBoundQuerySettings.DefaultModelBoundQuerySettings.MaxTop = maxTopValue;
}

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

namespace Microsoft.Test.E2E.AspNet.OData.Aggregation
{
public class AggregationTestsEFClassic: AggregationTests
public class AggregationTestsEFClassic: AggregationTests<AggregationTestsEFClassic>
{
public AggregationTestsEFClassic(WebHostTestFixture fixture)
public AggregationTestsEFClassic(WebHostTestFixture<AggregationTestsEFClassic> fixture)
: base(fixture)
{
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{
configuration.AddControllers(typeof(CustomersController));
base.UpdateConfiguration(configuration);

UpdateConfigureOnBase(configuration);
}

[Theory]
Expand All @@ -54,50 +55,50 @@ public async Task CustomAggregateStdDevWorks(string query)
}

#if NETCORE
public class AggregationTestsEFCoreInMemory : AggregationTests
public class AggregationTestsEFCoreInMemory : AggregationTests<AggregationTestsEFCoreInMemory>
{
public AggregationTestsEFCoreInMemory(WebHostTestFixture fixture)
public AggregationTestsEFCoreInMemory(WebHostTestFixture<AggregationTestsEFCoreInMemory> fixture)
: base(fixture)
{
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{
configuration.AddControllers(typeof(CoreCustomersController<AggregationContextCoreInMemory>));
base.UpdateConfiguration(configuration);

UpdateConfigureOnBase(configuration);
}
}

public class AggregationTestsEFCoreSql : AggregationTests
public class AggregationTestsEFCoreSql : AggregationTests<AggregationTestsEFCoreSql>
{
public AggregationTestsEFCoreSql(WebHostTestFixture fixture)
public AggregationTestsEFCoreSql(WebHostTestFixture<AggregationTestsEFCoreSql> fixture)
: base(fixture)
{
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{
configuration.AddControllers(typeof(CoreCustomersController<AggregationContextCoreSql>));
base.UpdateConfiguration(configuration);

UpdateConfigureOnBase(configuration);
}
}
#endif


#if !NETCORE
public class LinqToSqlAggregationTests : WebHostTestBase
public class LinqToSqlAggregationTests : WebHostTestBase<LinqToSqlAggregationTests>
{
protected string AggregationTestBaseUrl => "{0}/aggregation/Customers";

public LinqToSqlAggregationTests(WebHostTestFixture fixture)
public LinqToSqlAggregationTests(WebHostTestFixture<LinqToSqlAggregationTests> fixture)
: base(fixture)
{
}


protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{

configuration.AddControllers(typeof(LinqToSqlCustomersController));
configuration.JsonReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
configuration.Count().Filter().OrderBy().Expand().MaxTop(null);
Expand Down Expand Up @@ -128,16 +129,16 @@ public async Task ApplyThrows()
}
#endif

public abstract class AggregationTests : WebHostTestBase
public abstract class AggregationTests<T> : WebHostTestBase<T>
{
protected string AggregationTestBaseUrl => "{0}/aggregation/Customers";

public AggregationTests(WebHostTestFixture fixture)
public AggregationTests(WebHostTestFixture<T> fixture)
:base(fixture)
{
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigureOnBase(WebRouteConfiguration configuration)
{
configuration.JsonReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
configuration.Count().Filter().OrderBy().Expand().MaxTop(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

namespace Microsoft.Test.E2E.AspNet.OData.Aggregation
{
public class PagedAggregationTests : WebHostTestBase
public class PagedAggregationTests : WebHostTestBase<PagedAggregationTests>
{
private const string AggregationTestBaseUrl = "{0}/pagedaggregation/Customers";

public PagedAggregationTests(WebHostTestFixture fixture)
public PagedAggregationTests(WebHostTestFixture<PagedAggregationTests> fixture)
:base(fixture)
{
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{
configuration.AddControllers(typeof (Paged.CustomersController));
configuration.JsonReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.OData;

namespace Microsoft.Test.E2E.AspNet.OData.Aggregation.Paged
{
public class CustomersController : BaseCustomersController
public class CustomersController
{
[EnableQuery(PageSize = 5)]
public IQueryable<Customer> Get()
{
ResetDataSource();
var db = new AggregationContext();
return db.Customers;
return Generate().AsQueryable<Customer>();
}

public IList<Customer> Generate()
{
IList<Customer> customers = new List<Customer>();
for (int i = 1; i < 10; i++)
{
var customer = new Customer
{
Id = i,
Name = "Customer" + i % 2,
Bucket = i % 2 == 0 ? (CustomerBucket?)CustomerBucket.Small : null,
Order = new Order
{
Id = i,
Name = "Order" + i % 2,
Price = i * 100
},
Address = new Address
{
Name = "City" + i % 2,
Street = "Street" + i % 2,
}
};

customers.Add(customer);
}

customers.Add(new Customer()
{
Id = 10,
Name = null,
Bucket = CustomerBucket.Big,
Address = new Address
{
Name = "City1",
Street = "Street",
},
Order = new Order
{
Id = 10,
Name = "Order" + 10 % 2,
Price = 0
},
});

return customers;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

namespace Microsoft.Test.E2E.AspNet.OData.AlternateKeys
{
public class AlternateKeysTest : WebHostTestBase
public class AlternateKeysTest : WebHostTestBase<AlternateKeysTest>
{
public AlternateKeysTest(WebHostTestFixture fixture)
public AlternateKeysTest(WebHostTestFixture<AlternateKeysTest> fixture)
:base(fixture)
{
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{
var controllers = new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

namespace Microsoft.Test.E2E.AspNet.OData.AutoExpand
{
public class AutoExpandTests : WebHostTestBase
public class AutoExpandTests : WebHostTestBase<AutoExpandTests>
{
private const string AutoExpandTestBaseUrl = "{0}/autoexpand/Customers(5)";

public AutoExpandTests(WebHostTestFixture fixture)
public AutoExpandTests(WebHostTestFixture<AutoExpandTests> fixture)
:base(fixture)
{
}
Expand All @@ -39,18 +39,18 @@ public static TheoryDataSet<string, int> AutoExpandTestData
}
}

protected override void UpdateConfiguration(WebRouteConfiguration configuration)
protected static void UpdateConfigure(WebRouteConfiguration configuration)
{
configuration.AddControllers(
typeof (CustomersController),
typeof (CustomersController),
typeof (PeopleController),
typeof (NormalOrdersController));
configuration.JsonReferenceLoopHandling =
Newtonsoft.Json.ReferenceLoopHandling.Ignore;
configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select();
configuration.MapODataServiceRoute(
"autoexpand",
"autoexpand",
"autoexpand",
"autoexpand",
AutoExpandEdmModel.GetEdmModel(configuration));
}

Expand Down
Loading

0 comments on commit 8becfbf

Please sign in to comment.