Skip to content

Commit

Permalink
Re-enable more non-query tests
Browse files Browse the repository at this point in the history
Part of #15318 (Still open for in-memory tests)

See also #16359 and #16360
  • Loading branch information
ajcvickers committed Jun 30, 2019
1 parent 63a152b commit c520ecf
Show file tree
Hide file tree
Showing 16 changed files with 1,725 additions and 1,732 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public virtual void Inserting_dependent_with_just_one_parent_throws()
}
}

[ConditionalFact(Skip = "issue #15318")]
[ConditionalFact]
public virtual void Can_change_dependent_instance_non_derived()
{
using (CreateTestStore(
Expand Down
68 changes: 40 additions & 28 deletions test/EFCore.Specification.Tests/FieldMappingTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public virtual void Include_reference_auto_props(bool tracking)
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostAuto>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostAuto>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -180,7 +180,7 @@ public virtual void Include_reference_hiding_props(bool tracking)
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostHiding>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostHiding>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -243,7 +243,7 @@ public virtual void Include_reference_full_props(bool tracking)
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostFull>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostFull>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -306,7 +306,7 @@ public virtual void Include_reference_full_props_with_named_fields(bool tracking
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostFullExplicit>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostFullExplicit>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -369,7 +369,7 @@ public virtual void Include_reference_read_only_props(bool tracking)
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostReadOnly>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostReadOnly>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -432,7 +432,7 @@ public virtual void Include_reference_read_only_props_with_named_fields(bool tra
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostReadOnlyExplicit>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostReadOnlyExplicit>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -507,7 +507,7 @@ public virtual void Include_reference_write_only_props(bool tracking)
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostWriteOnly>().Include("Blog").AsTracking(tracking).ToList());
AssertGraph(context.Set<PostWriteOnly>().Include("Blog").AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -570,7 +570,7 @@ public virtual void Include_reference_write_only_props_with_named_fields(bool tr
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostWriteOnlyExplicit>().Include("Blog").AsTracking(tracking).ToList());
AssertGraph(context.Set<PostWriteOnlyExplicit>().Include("Blog").AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -633,7 +633,7 @@ public virtual void Include_reference_fields_only(bool tracking)
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostFields>().Include(e => e.Blog).AsTracking(tracking).ToList());
AssertGraph(context.Set<PostFields>().Include(e => e.Blog).AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -696,7 +696,7 @@ public virtual void Include_reference_fields_only_only_for_navs_too(bool trackin
{
using (var context = CreateContext())
{
AssertGraph(context.Set<PostNavFields>().Include("_blog").AsTracking(tracking).ToList());
AssertGraph(context.Set<PostNavFields>().Include("_blog").AsTracking(tracking).ToList(), tracking);
}
}

Expand Down Expand Up @@ -758,7 +758,7 @@ protected virtual void Load_reference<TPost>(string navigation)
context.Entry(post).Reference(navigation).Load();
}

AssertGraph(posts);
AssertGraph(posts, true);
}
}

Expand Down Expand Up @@ -888,32 +888,44 @@ protected void AssertGraph(IEnumerable<IBlogAccessor> blogs, string updated = ""
AssertPost(blog2.AccessPosts.Single(e => e.AccessId == 21), 21, blog2, updated);
}

private static void AssertPost(IPostAccessor post, int postId, IBlogAccessor blog1, string updated = "")
private static void AssertPost(IPostAccessor post, int postId, IBlogAccessor blog, string updated = "")
{
Assert.Equal("Post" + postId + updated, post.AccessTitle);
//issue #15318
//Assert.Same(blog1, post.AccessBlog);
Assert.Equal(blog1.AccessId, post.AccessBlogId);
Assert.Same(blog, post.AccessBlog);
Assert.Equal(blog.AccessId, post.AccessBlogId);
}

protected void AssertGraph(IEnumerable<IPostAccessor> posts)
protected void AssertGraph(IEnumerable<IPostAccessor> posts, bool tracking)
{
Assert.Equal(4, posts.Count());

var blog1 = posts.Select(e => e.AccessBlog).First(e => e.AccessId == 10);
Assert.Equal("Blog10", blog1.AccessTitle);
//issue #15318
//Assert.Equal(2, blog1.AccessPosts.Count());
AssertBlogs(posts, tracking, 10, 11, "Blog10");
AssertBlogs(posts, tracking, 20, 21, "Blog20");
}

private static void AssertBlogs(IEnumerable<IPostAccessor> posts, bool tracking, int post1Id, int post2Id, string blogName)
{
var blog1a = posts.Single(e => e.AccessId == post1Id).AccessBlog;
var blog1b = posts.Single(e => e.AccessId == post2Id).AccessBlog;

var blog2 = posts.Select(e => e.AccessBlog).First(e => e.AccessId == 20);
Assert.Equal("Blog20", blog2.AccessTitle);
//issue #15318
//Assert.Equal(2, blog1.AccessPosts.Count());
if (tracking)
{
Assert.Same(blog1a, blog1b);
Assert.Equal(blogName, blog1a.AccessTitle);
Assert.Equal(2, blog1a.AccessPosts.Count());
}
else
{
// Because no identity resolution for no-tracking
Assert.NotSame(blog1a, blog1b);
Assert.Equal(blogName, blog1a.AccessTitle);
Assert.Equal(blogName, blog1b.AccessTitle);
Assert.Equal(1, blog1a.AccessPosts.Count());
Assert.Equal(1, blog1b.AccessPosts.Count());
}

AssertPost(posts.Single(e => e.AccessId == 10), 10, blog1);
AssertPost(posts.Single(e => e.AccessId == 11), 11, blog1);
AssertPost(posts.Single(e => e.AccessId == 20), 20, blog2);
AssertPost(posts.Single(e => e.AccessId == 21), 21, blog2);
AssertPost(posts.Single(e => e.AccessId == post1Id), post1Id, blog1a);
AssertPost(posts.Single(e => e.AccessId == post2Id), post2Id, blog1b);
}

protected class BlogAuto : IBlogAccessor
Expand Down
18 changes: 4 additions & 14 deletions test/EFCore.Specification.Tests/GraphUpdatesTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,6 @@ public virtual void Save_required_one_to_one_changed_by_reference(
});
}

[ConditionalTheory (Skip = "Issue #15318")]
[InlineData((int)ChangeMechanism.Principal, false, CascadeTiming.OnSaveChanges)]
[InlineData((int)ChangeMechanism.Principal, true, CascadeTiming.OnSaveChanges)]
[InlineData((int)ChangeMechanism.Dependent, false, CascadeTiming.OnSaveChanges)]
Expand Down Expand Up @@ -3735,7 +3734,6 @@ public virtual void Save_required_one_to_one_changed_by_reference_with_alternate
});
}

[ConditionalTheory(Skip = "Issue #15318")]
[InlineData((int)ChangeMechanism.Principal, false, CascadeTiming.OnSaveChanges)]
[InlineData((int)ChangeMechanism.Principal, true, CascadeTiming.OnSaveChanges)]
[InlineData((int)ChangeMechanism.Dependent, false, CascadeTiming.OnSaveChanges)]
Expand Down Expand Up @@ -5968,9 +5966,7 @@ public virtual void Required_many_to_one_dependents_are_cascade_deleted_in_store
context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming ?? CascadeTiming.Never;
context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming ?? CascadeTiming.Never;

// Issue #15318 Change this back to a single query with Includes:
// var root = context.Set<Root>().Include(e => e.RequiredChildren).Single(IsTheRoot);
var root = context.Set<Root>().Single(IsTheRoot);
var root = context.Set<Root>().Include(e => e.RequiredChildren).Single(IsTheRoot);
context.Set<Required1>().Load();

var removed = root.RequiredChildren.Single(e => e.Id == removedId);
Expand Down Expand Up @@ -6225,9 +6221,7 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca
context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming ?? CascadeTiming.Never;
context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming ?? CascadeTiming.Never;

// Issue #15318 Change this back to a single query with Includes:
// var root = context.Set<Root>().Include(e => e.RequiredChildrenAk).Single(IsTheRoot);
var root = context.Set<Root>().Single(IsTheRoot);
var root = context.Set<Root>().Include(e => e.RequiredChildrenAk).Single(IsTheRoot);
context.Set<RequiredAk1>().Load();

var removed = root.RequiredChildrenAk.Single(e => e.Id == removedId);
Expand Down Expand Up @@ -6483,9 +6477,7 @@ public virtual void Optional_many_to_one_dependents_are_orphaned_in_store(
context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming ?? CascadeTiming.Never;
context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming ?? CascadeTiming.Never;

// Issue #15318 Change this back to a single query with Includes:
// var root = context.Set<Root>().Include(e => e.OptionalChildren).Single(IsTheRoot);
var root = context.Set<Root>().Single(IsTheRoot);
var root = context.Set<Root>().Include(e => e.OptionalChildren).Single(IsTheRoot);
context.Entry(root).Collection(e => e.OptionalChildren).Load();

var removed = root.OptionalChildren.First(e => e.Id == removedId);
Expand Down Expand Up @@ -6660,9 +6652,7 @@ public virtual void Optional_many_to_one_dependents_with_alternate_key_are_orpha
context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming ?? CascadeTiming.Never;
context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming ?? CascadeTiming.Never;

// Issue #15318 Change this back to a single query with Includes:
// var root = context.Set<Root>().Include(e => e.OptionalChildrenAk).Single(IsTheRoot);
var root = context.Set<Root>().Single(IsTheRoot);
var root = context.Set<Root>().Include(e => e.OptionalChildrenAk).Single(IsTheRoot);
context.Entry(root).Collection(e => e.OptionalChildrenAk).Load();

var removed = root.OptionalChildrenAk.First(e => e.Id == removedId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private static void AddEntities(F1Context context)
},
new TestDriver
{
Name = "Marc Gené",
Name = "Marc Gené",
TeamId = Team.Ferrari,
CarNumber = null,
Championships = 0,
Expand All @@ -548,7 +548,7 @@ private static void AddEntities(F1Context context)
},
new Driver
{
Name = "Nico Hülkenberg",
Name = "Nico Hülkenberg",
TeamId = Team.Williams,
CarNumber = 10,
Championships = 0,
Expand Down Expand Up @@ -608,7 +608,7 @@ private static void AddEntities(F1Context context)
},
new TestDriver
{
Name = "Jérôme d'Ambrosio",
Name = "Jérôme d'Ambrosio",
TeamId = Team.Renault,
CarNumber = null,
Championships = 0,
Expand Down Expand Up @@ -668,7 +668,7 @@ private static void AddEntities(F1Context context)
},
new Driver
{
Name = "Sébastien Buemi",
Name = "Sébastien Buemi",
TeamId = Team.ToroRosso,
CarNumber = 16,
Championships = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;

#pragma warning disable RCS1202 // Avoid NullReferenceException.

Expand Down Expand Up @@ -79,8 +80,8 @@ public void AssertSeeded()
.Include(v => ((PoweredVehicle)v).Engine)
.ThenInclude(e => (e as CombustionEngine).FuelTank)
.OrderBy(v => v.Name).ToList();
//issue #15318
//Assert.Equal(expected, actual);

Assert.Equal(expected, actual);
}

protected IEnumerable<Vehicle> CreateVehicles()
Expand Down
Loading

0 comments on commit c520ecf

Please sign in to comment.