Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(efcore): add support for not-stored columns, view columns
- handle not-stored columns such as NotMapped and HasComputedSql columns - validate column names and types on views
- Loading branch information
Showing
37 changed files
with
3,108 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...ntityframeworkcore2.validation.tests/SqlServer/WhenValidatingSchemaGivenMissingColumns.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using Aranasoft.Cobweb.EntityFrameworkCore.Validation.Tests.Support.Migrations; | ||
using Aranasoft.Cobweb.EntityFrameworkCore.Validation.Tests.Support.SqlServer; | ||
using Aranasoft.Cobweb.EntityFrameworkCore.Validation.Tests.Support.XUnit; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Aranasoft.Cobweb.EntityFrameworkCore.Validation.Tests.SqlServer { | ||
[OperatingSystemRequirement(OperatingSystems.Windows)] | ||
public class | ||
WhenValidatingSchemaGivenMissingColumns : IClassFixture<SqlServerMigrationsFixture<MigrationsMissingColumns>> { | ||
private readonly SqlServerMigrationsFixture<MigrationsMissingColumns> _fixture; | ||
|
||
public WhenValidatingSchemaGivenMissingColumns(SqlServerMigrationsFixture<MigrationsMissingColumns> fixture) { | ||
_fixture = fixture; | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldThrowValidationException() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should().ThrowExactly<SchemaValidationException>(); | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldHaveValidationErrors() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should() | ||
.Throw<SchemaValidationException>() | ||
.Which.ValidationErrors | ||
.Should() | ||
.NotBeEmpty(); | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldNotHaveMissingTableErrors() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should() | ||
.Throw<SchemaValidationException>() | ||
.Which.ValidationErrors | ||
.Should() | ||
.NotContain( | ||
error => error.StartsWith("Missing Table", | ||
StringComparison.InvariantCultureIgnoreCase)); | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldNotHaveMissingViewErrors() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should() | ||
.Throw<SchemaValidationException>() | ||
.Which.ValidationErrors | ||
.Should() | ||
.NotContain( | ||
error => error.StartsWith("Missing View", StringComparison.InvariantCultureIgnoreCase)); | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldOnlyHaveMissingColumnErrors() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should() | ||
.Throw<SchemaValidationException>() | ||
.Which.ValidationErrors | ||
.Should() | ||
.OnlyContain( | ||
error => error.StartsWith("Missing Column", | ||
StringComparison.InvariantCultureIgnoreCase)); | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldNotHaveMissingIndexErrors() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should() | ||
.Throw<SchemaValidationException>() | ||
.Which.ValidationErrors | ||
.Should() | ||
.NotContain( | ||
error => error.StartsWith("Missing Index", | ||
StringComparison.InvariantCultureIgnoreCase)); | ||
} | ||
|
||
[ConditionalFact] | ||
public void ItShouldNotHaveMissingForeignKeyErrors() { | ||
var applicationDbContext = _fixture.GetContext(); | ||
Action validatingSchema = () => applicationDbContext.ValidateSchema(); | ||
validatingSchema.Should() | ||
.Throw<SchemaValidationException>() | ||
.Which.ValidationErrors | ||
.Should() | ||
.NotContain(error => error.StartsWith("Missing Foreign Key", | ||
StringComparison.InvariantCultureIgnoreCase)); | ||
} | ||
} | ||
} |
Oops, something went wrong.