Skip to content

Commit

Permalink
Convert Inheritance query tests to AssertQuery infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
maumar committed Jul 2, 2020
1 parent e327d2c commit 5849bff
Show file tree
Hide file tree
Showing 31 changed files with 1,334 additions and 773 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Xunit;

Expand All @@ -14,10 +15,10 @@ public IncompleteMappingInheritanceQueryInMemoryTest(IncompleteMappingInheritanc
{
}

[ConditionalFact]
public override void Can_query_all_animal_views()
public override async Task Can_query_all_animal_views(bool async)
{
var message = Assert.Throws<InvalidOperationException>(() => base.Can_query_all_animal_views()).Message;
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Can_query_all_animal_views(async))).Message;

Assert.Equal(
CoreStrings.TranslationFailed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.TestModels.Inheritance;
using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;
using Microsoft.EntityFrameworkCore.TestUtilities;

namespace Microsoft.EntityFrameworkCore.Query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -16,10 +17,10 @@ public InheritanceQueryInMemoryTest(InheritanceQueryInMemoryFixture fixture, ITe
//TestLoggerFactory.TestOutputHelper = testOutputHelper;
}

[ConditionalFact]
public override void Can_query_all_animal_views()
public override async Task Can_query_all_animal_views(bool async)
{
var message = Assert.Throws<InvalidOperationException>(() => base.Can_query_all_animal_views()).Message;
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Can_query_all_animal_views(async))).Message;

Assert.Equal(
CoreStrings.TranslationFailed(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.TestModels.Inheritance;
using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;
using Microsoft.EntityFrameworkCore.TestUtilities;

namespace Microsoft.EntityFrameworkCore.Query
Expand Down Expand Up @@ -33,7 +33,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
modelBuilder.Entity<Tea>().Property(e => e.CaffeineGrams).HasColumnName("CaffeineGrams");

modelBuilder.Entity<AnimalQuery>().HasNoKey().ToQuery(
() => context.Set<AnimalQuery>().FromSqlRaw("SELECT * FROM Animal"));
() => context.Set<AnimalQuery>().FromSqlRaw("SELECT * FROM Animals"));
modelBuilder.Entity<KiwiQuery>().HasDiscriminator().HasValue("Kiwi");
modelBuilder.Entity<EagleQuery>().HasDiscriminator().HasValue("Eagle");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Linq;
using Microsoft.EntityFrameworkCore.TestModels.Inheritance;
using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit;

Expand All @@ -22,14 +22,14 @@ protected InheritanceRelationalQueryTestBase(TFixture fixture)
public virtual void FromSql_on_root()
{
using var context = CreateContext();
context.Set<Animal>().FromSqlRaw(NormalizeDelimitersInRawString("select * from [Animal]")).ToList();
context.Set<Animal>().FromSqlRaw(NormalizeDelimitersInRawString("select * from [Animals]")).ToList();
}

[ConditionalFact]
public virtual void FromSql_on_derived()
{
using var context = CreateContext();
context.Set<Eagle>().FromSqlRaw(NormalizeDelimitersInRawString("select * from [Animal]")).ToList();
context.Set<Eagle>().FromSqlRaw(NormalizeDelimitersInRawString("select * from [Animals]")).ToList();
}

[ConditionalFact]
Expand All @@ -44,7 +44,7 @@ public virtual void Casting_to_base_type_joining_with_query_type_works()
private void GetEntityWithAuditHistoryQuery<T>(InheritanceContext context, IQueryable<T> query)
where T : Animal
{
var queryTypeQuery = context.Set<AnimalQuery>().FromSqlRaw(NormalizeDelimitersInRawString("Select * from [Animal]"));
var queryTypeQuery = context.Set<AnimalQuery>().FromSqlRaw(NormalizeDelimitersInRawString("Select * from [Animals]"));

var animalQuery = query.Cast<Animal>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.TestModels.Inheritance;
using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;
using Microsoft.EntityFrameworkCore.TestUtilities;

namespace Microsoft.EntityFrameworkCore.Query
Expand Down
Loading

0 comments on commit 5849bff

Please sign in to comment.