Skip to content

Commit

Permalink
No skipped complex navigation tests
Browse files Browse the repository at this point in the history
Part of #26088
  • Loading branch information
ajcvickers committed Nov 7, 2021
1 parent 252ece7 commit de0e190
Show file tree
Hide file tree
Showing 30 changed files with 17,496 additions and 3,041 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.EntityFrameworkCore.Query
{
public class ComplexNavigationsCollectionsQueryInMemoryTest : ComplexNavigationsCollectionsQueryTestBase<ComplexNavigationsQueryInMemoryFixture>
public class ComplexNavigationsCollectionsQueryInMemoryTest
: ComplexNavigationsCollectionsQueryTestBase<ComplexNavigationsQueryInMemoryFixture>
{
public ComplexNavigationsCollectionsQueryInMemoryTest(ComplexNavigationsQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper)
public ComplexNavigationsCollectionsQueryInMemoryTest(
ComplexNavigationsQueryInMemoryFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
//TestLoggerFactory.TestOutputHelper = testOutputHelper;
}

public override async Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)
// Nested collection with ToList. Issue #23303.
=> await Assert.ThrowsAsync<ArgumentNullException>(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async));
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.EntityFrameworkCore.Query
{
public class ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest :
ComplexNavigationsCollectionsSharedTypeQueryTestBase<ComplexNavigationsSharedTypeQueryInMemoryFixture>
public class ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest
: ComplexNavigationsCollectionsSharedTypeQueryTestBase<ComplexNavigationsSharedTypeQueryInMemoryFixture>
{
// ReSharper disable once UnusedParameter.Local
public ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest(
ComplexNavigationsSharedTypeQueryInMemoryFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
//TestLoggerFactory.TestOutputHelper = testOutputHelper;
}

public override Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)
// Nested collection with ToList. Issue #23303.
=> Assert.ThrowsAsync<ArgumentNullException>(
() => base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.EntityFrameworkCore.Query
Expand All @@ -12,5 +15,10 @@ public ComplexNavigationsQueryInMemoryTest(ComplexNavigationsQueryInMemoryFixtur
{
//TestLoggerFactory.TestOutputHelper = testOutputHelper;
}

public override Task Join_with_result_selector_returning_queryable_throws_validation_error(bool async)
// Expression cannot be used for return type. Issue #23302.
=> Assert.ThrowsAsync<ArgumentException>(
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -18,5 +19,10 @@ public ComplexNavigationsSharedTypeQueryInMemoryTest(
{
//TestLoggerFactory.TestOutputHelper = testOutputHelper;
}

public override Task Join_with_result_selector_returning_queryable_throws_validation_error(bool async)
// Expression cannot be used for return type. Issue #23302.
=> Assert.ThrowsAsync<ArgumentException>(
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.EntityFrameworkCore.Query
Expand All @@ -12,7 +10,6 @@ public class NorthwindGroupByQueryInMemoryTest : NorthwindGroupByQueryTestBase<N
{
public NorthwindGroupByQueryInMemoryTest(
NorthwindQueryInMemoryFixture<NoopModelCustomizer> fixture,
// ReSharper disable once UnusedParameter.Local
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;

namespace Microsoft.EntityFrameworkCore.Query
{
Expand All @@ -20,9 +15,7 @@ protected ComplexNavigationsQueryRelationalTestBase(TFixture fixture)
}

public override Task Complex_query_with_optional_navigations_and_client_side_evaluation(bool async)
{
return AssertTranslationFailed(() => base.Complex_query_with_optional_navigations_and_client_side_evaluation(async));
}
=> AssertTranslationFailed(() => base.Complex_query_with_optional_navigations_and_client_side_evaluation(async));

protected virtual bool CanExecuteQueryString
=> false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class TestSqlLoggerFactory : ListLoggerFactory
private static readonly string _eol = Environment.NewLine;

private static readonly object _queryBaselineFileLock = new();
private static readonly HashSet<string> _overriddenMethods = new();

public TestSqlLoggerFactory()
: this(_ => true)
Expand Down Expand Up @@ -89,14 +90,17 @@ public void AssertBaseline(string[] expected, bool assertOrder = true)
0,
currentDirectory.LastIndexOf(
$"{Path.DirectorySeparatorChar}artifacts{Path.DirectorySeparatorChar}",
StringComparison.Ordinal) + 1)
StringComparison.Ordinal)
+ 1)
+ "QueryBaseline.txt";

var testInfo = testName + " : " + lineNumber + FileNewLine;
const string indent = FileNewLine + " ";

var sql = string.Join(
"," + indent + "//" + indent, SqlStatements.Take(9).Select(sql => "@\"" + sql.Replace("\"", "\"\"") + "\""));
var newBaseLine = $@" AssertSql(
{string.Join("," + indent + "//" + indent, SqlStatements.Take(9).Select(sql => "@\"" + sql.Replace("\"", "\"\"") + "\""))});
{sql});
";

Expand All @@ -110,9 +114,47 @@ public void AssertBaseline(string[] expected, bool assertOrder = true)

var contents = testInfo + newBaseLine + FileNewLine + "--------------------" + FileNewLine;

var indexSimpleMethodEnding = methodCallLine.IndexOf('(');
var indexSimpleMethodStarting = methodCallLine.LastIndexOf('.', indexSimpleMethodEnding) + 1;
var methodName = methodCallLine.Substring(indexSimpleMethodStarting, indexSimpleMethodEnding - indexSimpleMethodStarting);

var manipulatedSql = string.IsNullOrEmpty(sql)
? ""
: @$"
{sql}";

var overrideString = testName.Contains("Boolean async")
? @$" public override async Task {methodName}(bool async)
{{
await base.{methodName}(async);
AssertSql({manipulatedSql});
}}
"
: @$" public override void {methodName}()
{{
base.{methodName}();
AssertSql({manipulatedSql});
}}
";

lock (_queryBaselineFileLock)
{
File.AppendAllText(logFile, contents);

// if (!_overriddenMethods.Any())
// {
// File.Delete(logFile);
// }
//
// if (!_overriddenMethods.Contains(methodName))
// {
// File.AppendAllText(logFile, overrideString);
// _overriddenMethods.Add(methodName);
// }
}

throw;
Expand Down Expand Up @@ -147,8 +189,8 @@ protected override void UnsafeLog<TState>(
Exception exception)
{
if ((eventId.Id == RelationalEventId.CommandExecuted.Id
|| eventId.Id == RelationalEventId.CommandError.Id
|| eventId.Id == RelationalEventId.CommandExecuting.Id))
|| eventId.Id == RelationalEventId.CommandError.Id
|| eventId.Id == RelationalEventId.CommandExecuting.Id))
{
if (_shouldLogCommands)
{
Expand Down
Loading

0 comments on commit de0e190

Please sign in to comment.