Skip to content

Commit

Permalink
Remove the test for the quirk mode for #12227
Browse files Browse the repository at this point in the history
Disable GroupBy_Composite_Select_Dto_Sum_Min_Key_flattened_Max_Avg, flakiness seems external to EF

Fixes #12664
  • Loading branch information
AndriySvyryd committed Jul 13, 2018
1 parent 7a4539d commit e3848c8
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 187 deletions.
272 changes: 87 additions & 185 deletions src/EFCore.Specification.Tests/GraphUpdatesTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5704,229 +5704,131 @@ public virtual void Sometimes_not_calling_DetectChanges_when_required_does_not_t
{
ExecuteWithStrategyInTransaction(
context =>
{
var dependent = context.Set<BadOrder>().Single();
{
var dependent = context.Set<BadOrder>().Single();

dependent.BadCustomerId = null;
dependent.BadCustomerId = null;

var principal = context.Set<BadCustomer>().Single();
var principal = context.Set<BadCustomer>().Single();

principal.Status++;
principal.Status++;

Assert.Null(dependent.BadCustomerId);
Assert.Null(dependent.BadCustomer);
Assert.Empty(principal.BadOrders);
Assert.Null(dependent.BadCustomerId);
Assert.Null(dependent.BadCustomer);
Assert.Empty(principal.BadOrders);

context.SaveChanges();
context.SaveChanges();

Assert.Null(dependent.BadCustomerId);
Assert.Null(dependent.BadCustomer);
Assert.Empty(principal.BadOrders);
},
Assert.Null(dependent.BadCustomerId);
Assert.Null(dependent.BadCustomer);
Assert.Empty(principal.BadOrders);
},
context =>
{
var dependent = context.Set<BadOrder>().Single();
var principal = context.Set<BadCustomer>().Single();
{
var dependent = context.Set<BadOrder>().Single();
var principal = context.Set<BadCustomer>().Single();

Assert.Null(dependent.BadCustomerId);
Assert.Null(dependent.BadCustomer);
Assert.Empty(principal.BadOrders);
});
Assert.Null(dependent.BadCustomerId);
Assert.Null(dependent.BadCustomer);
Assert.Empty(principal.BadOrders);
});
}

[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public virtual void Can_add_valid_first_depedent_when_multiple_possible_principal_sides(bool quirk)
[ConditionalFact]
public virtual void Can_add_valid_first_depedent_when_multiple_possible_principal_sides()
{
try
{
if (quirk)
ExecuteWithStrategyInTransaction(
context =>
{
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue12227", true);
}
var quizTask = new QuizTask();
quizTask.Choices.Add(new TaskChoice());

ExecuteWithStrategyInTransaction(
context =>
{
var quizTask = new QuizTask();
quizTask.Choices.Add(new TaskChoice());
context.Add(quizTask);

if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Add(quizTask));
}
else
{
context.Add(quizTask);
}

context.SaveChanges();
},
context =>
{
if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Set<QuizTask>().Include(e => e.Choices).Single());
}
else
{
var quizTask = context.Set<QuizTask>().Include(e => e.Choices).Single();
context.SaveChanges();
},
context =>
{
var quizTask = context.Set<QuizTask>().Include(e => e.Choices).Single();

Assert.Equal(quizTask.Id, quizTask.Choices.Single().QuestTaskId);
Assert.Equal(quizTask.Id, quizTask.Choices.Single().QuestTaskId);

Assert.Same(quizTask.Choices.Single(), context.Set<TaskChoice>().Single());
Assert.Same(quizTask.Choices.Single(), context.Set<TaskChoice>().Single());

Assert.Empty(context.Set<HiddenAreaTask>().Include(e => e.Choices));
}
});
}
finally
{
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue12227", false);
}
Assert.Empty(context.Set<HiddenAreaTask>().Include(e => e.Choices));
});
}

[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public virtual void Can_add_valid_second_depedent_when_multiple_possible_principal_sides(bool quirk)
[ConditionalFact]
public virtual void Can_add_valid_second_depedent_when_multiple_possible_principal_sides()
{
try
{
if (quirk)
ExecuteWithStrategyInTransaction(
context =>
{
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue12227", true);
}
var hiddenAreaTask = new HiddenAreaTask();
hiddenAreaTask.Choices.Add(new TaskChoice());

ExecuteWithStrategyInTransaction(
context =>
{
var hiddenAreaTask = new HiddenAreaTask();
hiddenAreaTask.Choices.Add(new TaskChoice());

if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Add(hiddenAreaTask));
}
else
{
context.Add(hiddenAreaTask);
}
context.Add(hiddenAreaTask);

context.SaveChanges();
},
context =>
{
if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Set<HiddenAreaTask>().Include(e => e.Choices).Single());
}
else
{
var hiddenAreaTask = context.Set<HiddenAreaTask>().Include(e => e.Choices).Single();
context.SaveChanges();
},
context =>
{
var hiddenAreaTask = context.Set<HiddenAreaTask>().Include(e => e.Choices).Single();

Assert.Equal(hiddenAreaTask.Id, hiddenAreaTask.Choices.Single().QuestTaskId);
Assert.Equal(hiddenAreaTask.Id, hiddenAreaTask.Choices.Single().QuestTaskId);

Assert.Same(hiddenAreaTask.Choices.Single(), context.Set<TaskChoice>().Single());
Assert.Same(hiddenAreaTask.Choices.Single(), context.Set<TaskChoice>().Single());

Assert.Empty(context.Set<QuizTask>().Include(e => e.Choices));
}
});
}
finally
{
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue12227", false);
}
Assert.Empty(context.Set<QuizTask>().Include(e => e.Choices));
});
}

[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public virtual void Can_add_multiple_depedents_when_multiple_possible_principal_sides(bool quirk)
[ConditionalFact]
public virtual void Can_add_multiple_depedents_when_multiple_possible_principal_sides()
{
try
{
if (quirk)
ExecuteWithStrategyInTransaction(
context =>
{
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue12227", true);
}
var quizTask = new QuizTask();
quizTask.Choices.Add(new TaskChoice());
quizTask.Choices.Add(new TaskChoice());

ExecuteWithStrategyInTransaction(
context =>
{
var quizTask = new QuizTask();
quizTask.Choices.Add(new TaskChoice());
quizTask.Choices.Add(new TaskChoice());
context.Add(quizTask);

if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Add(quizTask));
}
else
{
context.Add(quizTask);
}
var hiddenAreaTask = new HiddenAreaTask();
hiddenAreaTask.Choices.Add(new TaskChoice());
hiddenAreaTask.Choices.Add(new TaskChoice());

var hiddenAreaTask = new HiddenAreaTask();
hiddenAreaTask.Choices.Add(new TaskChoice());
hiddenAreaTask.Choices.Add(new TaskChoice());
context.Add(hiddenAreaTask);

if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Add(hiddenAreaTask));
}
else
{
context.Add(hiddenAreaTask);
}
context.SaveChanges();
},
context =>
{
var quizTask = context.Set<QuizTask>().Include(e => e.Choices).Single();
var hiddenAreaTask = context.Set<HiddenAreaTask>().Include(e => e.Choices).Single();

context.SaveChanges();
},
context =>
Assert.Equal(2, quizTask.Choices.Count);
foreach (var quizTaskChoice in quizTask.Choices)
{
if (quirk)
{
Assert.Throws<InvalidOperationException>(
() => context.Set<QuizTask>().Include(e => e.Choices).Single());
}
else
{
var quizTask = context.Set<QuizTask>().Include(e => e.Choices).Single();
var hiddenAreaTask = context.Set<HiddenAreaTask>().Include(e => e.Choices).Single();

Assert.Equal(2, quizTask.Choices.Count);
foreach (var quizTaskChoice in quizTask.Choices)
{
Assert.Equal(quizTask.Id, quizTaskChoice.QuestTaskId);
}
Assert.Equal(quizTask.Id, quizTaskChoice.QuestTaskId);
}

Assert.Equal(2, hiddenAreaTask.Choices.Count);
foreach (var hiddenAreaTaskChoice in hiddenAreaTask.Choices)
{
Assert.Equal(hiddenAreaTask.Id, hiddenAreaTaskChoice.QuestTaskId);
}
Assert.Equal(2, hiddenAreaTask.Choices.Count);
foreach (var hiddenAreaTaskChoice in hiddenAreaTask.Choices)
{
Assert.Equal(hiddenAreaTask.Id, hiddenAreaTaskChoice.QuestTaskId);
}

foreach (var taskChoice in context.Set<TaskChoice>())
{
Assert.Equal(
1,
quizTask.Choices.Count(e => e.Id == taskChoice.Id)
+ hiddenAreaTask.Choices.Count(e => e.Id == taskChoice.Id));
}
}
});
}
finally
{
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue12227", false);
}
foreach (var taskChoice in context.Set<TaskChoice>())
{
Assert.Equal(
1,
quizTask.Choices.Count(e => e.Id == taskChoice.Id)
+ hiddenAreaTask.Choices.Count(e => e.Id == taskChoice.Id));
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ private bool Equals(NominalType other)
&& EmployeeID == other.EmployeeID;
}

[ConditionalFact]
[ConditionalFact(Skip = "https://github.com/dotnet/corefx/issues/30955")]
public virtual async Task GroupBy_Composite_Select_Dto_Sum_Min_Key_flattened_Max_Avg()
{
await AssertQuery<Order>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private bool Equals(NominalType other)
&& EmployeeID == other.EmployeeID;
}

[ConditionalFact]
[ConditionalFact(Skip = "https://github.com/dotnet/corefx/issues/30955")]
public virtual void GroupBy_Composite_Select_Dto_Sum_Min_Key_flattened_Max_Avg()
{
AssertQuery<Order>(
Expand Down

0 comments on commit e3848c8

Please sign in to comment.