Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use raw string literals in scaffolding tests #29965

Merged
1 commit merged into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@ public void Migrations_compile()
},
Array.Empty<MigrationOperation>());
Assert.Equal(
@"using System.Text.RegularExpressions;
"""
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
Expand All @@ -566,23 +567,23 @@ public partial class MyMigration : Migration
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(""-- TEST"")
.Annotation(""Some:EnumValue"", RegexOptions.Multiline);
migrationBuilder.Sql("-- TEST")
.Annotation("Some:EnumValue", RegexOptions.Multiline);

migrationBuilder.AlterColumn<Database>(
name: ""C2"",
table: ""T1"",
name: "C2",
table: "T1",
nullable: false,
oldClrType: typeof(Property));

migrationBuilder.AddColumn<PropertyEntry>(
name: ""C3"",
table: ""T1"",
name: "C3",
table: "T1",
nullable: false);

migrationBuilder.InsertData(
table: ""T1"",
columns: new[] { ""Id"", ""C2"", ""C3"" },
table: "T1",
columns: new[] { "Id", "C2", "C3" },
values: new object[] { 1, null, -1 });
}

Expand All @@ -593,7 +594,8 @@ protected override void Down(MigrationBuilder migrationBuilder)
}
}
}
",

""",
migrationCode,
ignoreLineEndingDifferences: true);

Expand All @@ -619,7 +621,8 @@ protected override void Down(MigrationBuilder migrationBuilder)
"20150511161616_MyMigration",
finalizedModel);
Assert.Equal(
@"// <auto-generated />
"""
// <auto-generated />
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand All @@ -632,36 +635,37 @@ protected override void Down(MigrationBuilder migrationBuilder)
namespace MyNamespace
{
[DbContext(typeof(CSharpMigrationsGeneratorTest.MyContext))]
[Migration(""20150511161616_MyMigration"")]
[Migration("20150511161616_MyMigration")]
partial class MyMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation(""Some:EnumValue"", RegexOptions.Multiline);
modelBuilder.HasAnnotation("Some:EnumValue", RegexOptions.Multiline);

modelBuilder.Entity(""T1"", b =>
modelBuilder.Entity("T1", b =>
{
b.Property<int>(""Id"")
.HasColumnType(""int"");
b.Property<int>("Id")
.HasColumnType("int");

b.Property<string>(""C2"")
b.Property<string>("C2")
.IsRequired()
.HasColumnType(""nvarchar(max)"");
.HasColumnType("nvarchar(max)");

b.Property<int>(""C3"")
.HasColumnType(""int"");
b.Property<int>("C3")
.HasColumnType("int");

b.HasKey(""Id"");
b.HasKey("Id");

b.ToTable(""T1"");
b.ToTable("T1");
});
#pragma warning restore 612, 618
}
}
}
",

""",
migrationMetadataCode,
ignoreLineEndingDifferences: true);

Expand Down Expand Up @@ -753,7 +757,8 @@ public void Snapshots_compile()
"MySnapshot",
finalizedModel);
Assert.Equal(
@"// <auto-generated />
"""
// <auto-generated />
using System;
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
Expand All @@ -771,39 +776,40 @@ partial class MySnapshot : ModelSnapshot
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation(""Some:EnumValue"", RegexOptions.Multiline);
modelBuilder.HasAnnotation("Some:EnumValue", RegexOptions.Multiline);

modelBuilder.Entity(""Cheese"", b =>
modelBuilder.Entity("Cheese", b =>
{
b.Property<string>(""Ham"")
.HasColumnType(""just_string(10)"");
b.Property<string>("Ham")
.HasColumnType("just_string(10)");

b.Property<string>(""Pickle"")
.HasColumnType(""just_string(10)"");
b.Property<string>("Pickle")
.HasColumnType("just_string(10)");

b.HasKey(""Ham"");
b.HasKey("Ham");

b.ToTable(""Cheese"");
b.ToTable("Cheese");
});

modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+EntityWithConstructorBinding"", b =>
modelBuilder.Entity("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+EntityWithConstructorBinding", b =>
{
b.Property<int>(""Id"")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType(""default_int_mapping"");
.HasColumnType("default_int_mapping");

b.Property<Guid>(""PropertyWithValueGenerator"")
.HasColumnType(""default_guid_mapping"");
b.Property<Guid>("PropertyWithValueGenerator")
.HasColumnType("default_guid_mapping");

b.HasKey(""Id"");
b.HasKey("Id");

b.ToTable(""EntityWithConstructorBinding"");
b.ToTable("EntityWithConstructorBinding");
});
#pragma warning restore 612, 618
}
}
}
", modelSnapshotCode, ignoreLineEndingDifferences: true);

""", modelSnapshotCode, ignoreLineEndingDifferences: true);

var snapshot = CompileModelSnapshot(modelSnapshotCode, "MyNamespace.MySnapshot");
Assert.Equal(2, snapshot.Model.GetEntityTypes().Count());
Expand Down
Loading