Skip to content

Commit f34e92c

Browse files
authored
#14 Include(...) after AsExpandable() (#165)
tests
1 parent 95f71da commit f34e92c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

tests/LinqKit.EntityFramework.Tests.Net452/DbAsyncTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public DbAsyncTests()
3636
_db.Entities.RemoveRange(_db.Entities.ToList());
3737
_db.Entities.AddRange(new[]
3838
{
39+
new Entity { Value = 1024, RelatedEntity = new RelatedEntity { Value = 2048 } },
3940
new Entity { Value = 123 },
4041
new Entity { Value = 67 },
4142
new Entity { Value = 3 }
@@ -63,7 +64,7 @@ public async Task DbAsync_EnumerateShouldWorkAsync()
6364
var after = task.Status;
6465

6566
Assert.Equal(TaskStatus.RanToCompletion, after);
66-
Assert.Equal(3, result.Count);
67+
Assert.Equal(4, result.Count);
6768
}
6869

6970
[Fact]
@@ -142,5 +143,19 @@ public async Task DbAsync_ExpressionStarter_With_Optimizer()
142143
// Verify
143144
optimizerMock.Verify(o => o(It.IsAny<Expression>()), Times.Once);
144145
}
146+
147+
[Fact]
148+
public async Task DbAsync_IncludeAfterAsExpandableShouldWorkAsync()
149+
{
150+
var entity = await _db.Entities.AsNoTracking().AsExpandable().Include(e => e.RelatedEntity).Where(e => e.Value == 1024).SingleAsync();
151+
Assert.Equal(2048, entity.RelatedEntity?.Value);
152+
}
153+
154+
[Fact]
155+
public async Task DbAsync_IncludeBeforeAsExpandableShouldWorkAsync()
156+
{
157+
var entity = await _db.Entities.AsNoTracking().Include(e => e.RelatedEntity).AsExpandable().Where(e => e.Value == 1024).SingleAsync();
158+
Assert.Equal(2048, entity.RelatedEntity?.Value);
159+
}
145160
}
146161
}

tests/LinqKit.EntityFramework.Tests.Net452/Entity.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,14 @@ public class Entity
66
public int Id { get; set; }
77

88
public int Value { get; set; }
9+
10+
public RelatedEntity RelatedEntity { get; set; }
11+
}
12+
13+
public class RelatedEntity
14+
{
15+
public int Id { get; set; }
16+
17+
public int Value { get; set; }
918
}
1019
}

tests/LinqKit.EntityFramework.Tests.Net452/TestContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public TestContext(DbContextOptions options) : base(options)
1818
}
1919

2020
public DbSet<Entity> Entities { get; set; }
21+
public DbSet<RelatedEntity> RelatedEntities { get; set; }
2122
}
2223
#else
2324
[DbConfigurationType(typeof(CodeConfig))]
@@ -31,6 +32,7 @@ public TestContext(string nameOrConnectionString) : base(nameOrConnectionString)
3132
}
3233

3334
public DbSet<Entity> Entities { get; set; }
35+
public DbSet<RelatedEntity> RelatedEntities { get; set; }
3436
}
3537

3638
public class CodeConfig : DbConfiguration

0 commit comments

Comments
 (0)