From 32be8c88ca550b867749f23e490d3cbd7d05a78f Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 24 May 2020 11:12:32 +1000 Subject: [PATCH 1/3] update toe Verify v4 --- src/Directory.Build.props | 2 +- src/Verify.EntityFramework/Verify.EntityFramework.csproj | 2 +- .../Verify.EntityFrameworkClassic.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 79cbc593..b9ff251f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ CS1591;CS0649;CS8632 - 1.1.0 + 1.2.0 1.0.0 EntityFramework, Verify Extends Verify (https://github.com/VerifyTests/Verify) to allow verification of EntityFramework bits. diff --git a/src/Verify.EntityFramework/Verify.EntityFramework.csproj b/src/Verify.EntityFramework/Verify.EntityFramework.csproj index a0d11d17..91381db4 100644 --- a/src/Verify.EntityFramework/Verify.EntityFramework.csproj +++ b/src/Verify.EntityFramework/Verify.EntityFramework.csproj @@ -4,7 +4,7 @@ - + diff --git a/src/Verify.EntityFrameworkClassic/Verify.EntityFrameworkClassic.csproj b/src/Verify.EntityFrameworkClassic/Verify.EntityFrameworkClassic.csproj index 9afab557..cace4951 100644 --- a/src/Verify.EntityFrameworkClassic/Verify.EntityFrameworkClassic.csproj +++ b/src/Verify.EntityFrameworkClassic/Verify.EntityFrameworkClassic.csproj @@ -4,7 +4,7 @@ - + From c2faa72e5762d01b67ee982201ad5aee68f41709 Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 24 May 2020 11:20:04 +1000 Subject: [PATCH 2/3] . --- src/Verify.EntityFramework/Converters/QueryableConverter.cs | 3 ++- src/Verify.EntityFramework/VerifyEntityFramework.cs | 5 ++++- src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs | 3 ++- .../Snippets/DbContextBuilder.cs | 2 +- .../Converters/QueryableConverter.cs | 3 ++- .../VerifyEntityFrameworkClassic.cs | 5 ++++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Verify.EntityFramework/Converters/QueryableConverter.cs b/src/Verify.EntityFramework/Converters/QueryableConverter.cs index b848a637..2ebde4a9 100644 --- a/src/Verify.EntityFramework/Converters/QueryableConverter.cs +++ b/src/Verify.EntityFramework/Converters/QueryableConverter.cs @@ -36,8 +36,9 @@ public override bool CanConvert(Type type) return IsQueryable(type); } - public static bool IsQueryable(Type type) + public static bool IsQueryable(object target) { + var type = target.GetType(); if (!type.IsGenericType) { return false; diff --git a/src/Verify.EntityFramework/VerifyEntityFramework.cs b/src/Verify.EntityFramework/VerifyEntityFramework.cs index e06ddf62..3f6f4416 100644 --- a/src/Verify.EntityFramework/VerifyEntityFramework.cs +++ b/src/Verify.EntityFramework/VerifyEntityFramework.cs @@ -7,7 +7,10 @@ public static class VerifyEntityFramework { public static void Enable() { - SharedVerifySettings.RegisterFileConverter("txt", QueryableToSql, QueryableConverter.IsQueryable); + SharedVerifySettings.RegisterFileConverter( + "txt", + QueryableToSql, + QueryableConverter.IsQueryable); SharedVerifySettings.ModifySerialization(settings => { settings.AddExtraSettings(serializer => diff --git a/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs b/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs index 6f534110..66ee050c 100644 --- a/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs +++ b/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs @@ -129,6 +129,7 @@ public CoreTests(ITestOutputHelper output) : static CoreTests() { sqlInstance = new SqlInstance( - constructInstance: connection => new SampleDbContext(connection),instanceSuffix:"Tests"); + constructInstance: connection => new SampleDbContext(connection), + storage: Storage.FromSuffix("Tests")); } } \ No newline at end of file diff --git a/src/Verify.EntityFrameworkClassic.Tests/Snippets/DbContextBuilder.cs b/src/Verify.EntityFrameworkClassic.Tests/Snippets/DbContextBuilder.cs index 9a5f8f87..eb44876a 100644 --- a/src/Verify.EntityFrameworkClassic.Tests/Snippets/DbContextBuilder.cs +++ b/src/Verify.EntityFrameworkClassic.Tests/Snippets/DbContextBuilder.cs @@ -10,7 +10,7 @@ static DbContextBuilder() sqlInstance = new SqlInstance( buildTemplate: CreateDb, constructInstance: connection => new SampleDbContext(connection), - instanceSuffix: "Classic"); + storage: Storage.FromSuffix("Classic")); } static SqlInstance sqlInstance; diff --git a/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs b/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs index 66dc20df..d66cb7ed 100644 --- a/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs +++ b/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs @@ -35,8 +35,9 @@ public override bool CanConvert(Type type) return IsQueryable(type); } - public static bool IsQueryable(Type type) + public static bool IsQueryable(object target) { + var type = target.GetType(); if (!type.IsGenericType) { return false; diff --git a/src/Verify.EntityFrameworkClassic/VerifyEntityFrameworkClassic.cs b/src/Verify.EntityFrameworkClassic/VerifyEntityFrameworkClassic.cs index 70327cf1..cd499cef 100644 --- a/src/Verify.EntityFrameworkClassic/VerifyEntityFrameworkClassic.cs +++ b/src/Verify.EntityFrameworkClassic/VerifyEntityFrameworkClassic.cs @@ -7,7 +7,10 @@ public static class VerifyEntityFrameworkClassic { public static void Enable() { - SharedVerifySettings.RegisterFileConverter("txt", QueryableToSql, QueryableConverter.IsQueryable); + SharedVerifySettings.RegisterFileConverter( + "txt", + QueryableToSql, + QueryableConverter.IsQueryable); SharedVerifySettings.ModifySerialization(settings => { settings.AddExtraSettings(serializer => From f3fe989f8f08292b2067bfe27dabc7e601141f8e Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 24 May 2020 16:04:39 +1000 Subject: [PATCH 3/3] . --- src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs | 10 +++++----- .../Converters/QueryableConverter.cs | 9 +-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs b/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs index 66ee050c..d4a481ab 100644 --- a/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs +++ b/src/Verify.EntityFrameworkClassic.Tests/CoreTests.cs @@ -121,15 +121,15 @@ public async Task Queryable() } #endregion - public CoreTests(ITestOutputHelper output) : - base(output) - { - } - static CoreTests() { sqlInstance = new SqlInstance( constructInstance: connection => new SampleDbContext(connection), storage: Storage.FromSuffix("Tests")); } + + public CoreTests(ITestOutputHelper output) : + base(output) + { + } } \ No newline at end of file diff --git a/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs b/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs index d66cb7ed..dbdb51ef 100644 --- a/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs +++ b/src/Verify.EntityFrameworkClassic/Converters/QueryableConverter.cs @@ -37,13 +37,6 @@ public override bool CanConvert(Type type) public static bool IsQueryable(object target) { - var type = target.GetType(); - if (!type.IsGenericType) - { - return false; - } - - var genericType = type.GetGenericTypeDefinition(); - return genericType == typeof(IQueryable<>); + return target is IQueryable; } } \ No newline at end of file