Skip to content

Commit

Permalink
Add test and small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ralmsdeveloper committed Apr 18, 2020
1 parent 1bc7387 commit 23be175
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ FROM [sys].[indexes] i
IsUnique: ddr.GetValueOrDefault<bool>("is_unique"),
HasFilter: ddr.GetValueOrDefault<bool>("has_filter"),
FilterDefinition: ddr.GetValueOrDefault<string>("filter_definition"),
FillFactor: ddr.GetValueOrDefault<int>("fill_factor")))
FillFactor: ddr.GetValueOrDefault<byte>("fill_factor")))
.ToArray();

foreach (var indexGroup in indexGroups)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public void Can_set_index_online_non_generic()
var modelBuilder = CreateConventionModelBuilder();

modelBuilder
.Entity<Customer>()
.HasIndex(e => e.Name)
.Entity(typeof(Customer))
.HasIndex("Name")
.IsCreatedOnline();

var index = modelBuilder.Model.FindEntityType(typeof(Customer)).GetIndexes().Single();
Expand Down Expand Up @@ -770,10 +770,8 @@ public void Can_set_index_with_fillfactor_non_generic()
}

[ConditionalTheory]
[InlineData(-1)]
[InlineData(0)]
[InlineData(101)]
[InlineData(int.MinValue)]
[InlineData(int.MaxValue)]
public void Can_set_index_with_fillfactor_argument_out_of_range_exception(int fillFactor)
{
var modelBuilder = CreateConventionModelBuilder();
Expand Down
51 changes: 51 additions & 0 deletions test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,5 +1003,56 @@ public void Rebuild_index_when_changing_fillfactor_option()
Assert.Empty(operation2.GetAnnotations());
});
}

[ConditionalFact]
public void Rebuild_index_with_different_fillfactor_option()
{
Execute(
source => source
.Entity(
"Address",
x =>
{
x.Property<int>("Id");
x.Property<string>("Zip");
x.Property<string>("City");
x.Property<string>("Street");
x.HasIndex("Zip")
.HasFillFactor(50);
}),
target => target
.Entity(
"Address",
x =>
{
x.Property<int>("Id");
x.Property<string>("Zip");
x.Property<string>("City");
x.Property<string>("Street");
x.HasIndex("Zip")
.HasFillFactor(90);
}),
operations =>
{
Assert.Equal(2, operations.Count);
var operation1 = Assert.IsType<DropIndexOperation>(operations[0]);
Assert.Equal("Address", operation1.Table);
Assert.Equal("IX_Address_Zip", operation1.Name);
Assert.Empty(operation1.GetAnnotations());
var operation2 = Assert.IsType<CreateIndexOperation>(operations[1]);
Assert.Equal("Address", operation1.Table);
Assert.Equal("IX_Address_Zip", operation1.Name);
var annotation = operation2.GetAnnotation(SqlServerAnnotationNames.FillFactor);
Assert.NotNull(annotation);
var annotationValue = Assert.IsType<int>(annotation.Value);
Assert.Equal(90, annotationValue);
});
}
}
}

0 comments on commit 23be175

Please sign in to comment.