Skip to content

Commit

Permalink
Move some provider-facing tests to specifications
Browse files Browse the repository at this point in the history
* Moved to specifications: ApiConsistency, MigrationsSqlGenerator,
  UpdateSqlGeneratorTestBase, ModelValidatorTestBase (and Relational)
* Rearranged migrations tests under Migrations folder
* Reorganized SqlGenerationHelperTest split to simple, separate
  RelationalSqlGenerationHelperTest and
  SqlServerSqlGenerationHelperTest
* Suppress warning for underscores in test names

Closes #11500
  • Loading branch information
roji committed Sep 17, 2020
1 parent e33ea94 commit 495e0e3
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 69 deletions.
2 changes: 1 addition & 1 deletion test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn);1591;xUnit1000;xUnit1003;xUnit1004;xUnit1010;xUnit1013;xUnit1026</NoWarn>
<NoWarn>$(NoWarn);CA1707;1591;xUnit1000;xUnit1003;xUnit1004;xUnit1010;xUnit1013;xUnit1026</NoWarn>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using Xunit;

// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
public abstract class MigrationsInfrastructureTestBase<TFixture> : IClassFixture<TFixture>
where TFixture : MigrationsInfrastructureFixtureBase, new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
public abstract class MigrationsTestBase<TFixture> : IClassFixture<TFixture>
where TFixture : MigrationsTestBase<TFixture>.MigrationsFixtureBase, new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,7 @@ protected ModificationCommand CreateInsertCommand(bool identityKey = true, bool
columnModifications = columnModifications.Where(c => !c.IsWrite).ToArray();
}

return new FakeModificationCommand(
"Ducks", Schema, new ParameterNameGenerator().GenerateNext, false, columnModifications);
return new ModificationCommand("Ducks", Schema, columnModifications, false);
}

protected ModificationCommand CreateUpdateCommand(bool isComputed = true, bool concurrencyToken = true)
Expand Down Expand Up @@ -736,8 +735,7 @@ protected ModificationCommand CreateUpdateCommand(bool isComputed = true, bool c
concurrencyProperty.GetTableColumnMappings().Single().TypeMapping, false, true, false, concurrencyToken, true)
};

return new FakeModificationCommand(
"Ducks", Schema, new ParameterNameGenerator().GenerateNext, false, columnModifications);
return new ModificationCommand("Ducks", Schema, columnModifications, false);
}

protected ModificationCommand CreateDeleteCommand(bool concurrencyToken = true)
Expand All @@ -759,8 +757,7 @@ protected ModificationCommand CreateDeleteCommand(bool concurrencyToken = true)
concurrencyProperty.GetTableColumnMappings().Single().TypeMapping, false, false, false, concurrencyToken, true)
};

return new FakeModificationCommand(
"Ducks", Schema, new ParameterNameGenerator().GenerateNext, false, columnModifications);
return new ModificationCommand("Ducks", Schema, columnModifications, false);
}

protected abstract TestHelpers TestHelpers { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Xunit;

namespace Microsoft.EntityFrameworkCore.Storage
{
public class RelationalSqlGenerationHelperTest : SqlGenerationHelperTestBase
public class RelationalSqlGenerationHelperTest
{
protected override ISqlGenerationHelper CreateSqlGenerationHelper()
[ConditionalFact]
public void GenerateParameterName_returns_parameter_name()
=> Assert.Equal("@name", CreateSqlGenerationHelper().GenerateParameterName("name"));

[ConditionalFact]
public void Default_BatchCommandSeparator_is_semicolon()
=> Assert.Equal(";", CreateSqlGenerationHelper().StatementTerminator);

[ConditionalFact]
public void BatchSeparator_returns_separator()
=> Assert.Equal(Environment.NewLine, CreateSqlGenerationHelper().BatchTerminator);

private ISqlGenerationHelper CreateSqlGenerationHelper()
=> new RelationalSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());
}
}

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using Xunit;

// ReSharper disable InconsistentNaming
namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
[SqlServerCondition(SqlServerCondition.IsNotSqlAzure | SqlServerCondition.IsNotCI)]
public class MigrationsInfrastructureSqlServerTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#nullable enable

namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
public class MigrationsSqlServerTest : MigrationsTestBase<MigrationsSqlServerTest.MigrationsSqlServerFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

namespace Microsoft.EntityFrameworkCore.Storage
{
public class SqlServerSqlGenerationHelperTest : SqlGenerationHelperTestBase
public class SqlServerSqlGenerationHelperTest
{
public override void BatchSeparator_returns_separator()
{
Assert.Equal("GO" + Environment.NewLine + Environment.NewLine, CreateSqlGenerationHelper().BatchTerminator);
}
[ConditionalFact]
public void BatchSeparator_returns_separator()
=> Assert.Equal("GO" + Environment.NewLine + Environment.NewLine, CreateSqlGenerationHelper().BatchTerminator);

protected override ISqlGenerationHelper CreateSqlGenerationHelper()
private ISqlGenerationHelper CreateSqlGenerationHelper()
=> new SqlServerSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using ModelSnapshot22;
using Xunit;

namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
public class MigrationsInfrastructureSqliteTest
: MigrationsInfrastructureTestBase<MigrationsInfrastructureSqliteTest.MigrationsInfrastructureSqliteFixture>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#nullable enable

namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
public class MigrationsSqliteTest : MigrationsTestBase<MigrationsSqliteTest.MigrationsSqliteFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Xunit;

namespace Microsoft.EntityFrameworkCore
namespace Microsoft.EntityFrameworkCore.Migrations
{
public class SqliteMigrationBuilderTest
{
Expand Down
13 changes: 0 additions & 13 deletions test/EFCore.Sqlite.Tests/Storage/SqliteSqlGenerationHelperTest.cs

This file was deleted.

0 comments on commit 495e0e3

Please sign in to comment.