From c2a4a125e02e21530f942ab511ff0882e0c019dd Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Sat, 11 Jul 2020 13:19:08 -0700 Subject: [PATCH] Move JSON serialization tests out of query tests Fixes #21538 Also add regression test for serialization of proxies Fixes #19403 --- .../SerializationInMemoryTest.cs | 13 + .../LazyLoadProxyTestBase.cs | 152 ++++++++++++ .../Query/NorthwindIncludeQueryTestBase.cs | 233 ------------------ .../SerializationTestBase.cs | 156 ++++++++++++ .../NorthwindIncludeQuerySqlServerTest.cs | 8 +- ...NorthwindSplitIncludeQuerySqlServerTest.cs | 8 +- .../SerializationSqlServerTest.cs | 13 + .../SerializationSqliteTest.cs | 13 + 8 files changed, 349 insertions(+), 247 deletions(-) create mode 100644 test/EFCore.InMemory.FunctionalTests/SerializationInMemoryTest.cs create mode 100644 test/EFCore.Specification.Tests/SerializationTestBase.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/SerializationSqlServerTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/SerializationSqliteTest.cs diff --git a/test/EFCore.InMemory.FunctionalTests/SerializationInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/SerializationInMemoryTest.cs new file mode 100644 index 00000000000..9827807b2a1 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/SerializationInMemoryTest.cs @@ -0,0 +1,13 @@ +// 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. + +namespace Microsoft.EntityFrameworkCore +{ + public class SerializationInMemoryTest : SerializationTestBase + { + public SerializationInMemoryTest(F1InMemoryFixture fixture) + : base(fixture) + { + } + } +} diff --git a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs index a4f76605987..3c4753f9fa8 100644 --- a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs +++ b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs @@ -4,7 +4,10 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; +using System.IO; using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; @@ -2030,6 +2033,155 @@ public virtual async Task Load_collection(EntityState state, bool async) Assert.Equal(3, context.ChangeTracker.Entries().Count()); } + [ConditionalFact] + public virtual void Can_serialize_proxies_to_JSON() + { + using var context = CreateContext(lazyLoadingEnabled: true); + + var blogs = context.Set().OrderBy(e => e.Host.HostName).ToList(); + + VerifyBlogs(blogs); + foreach (var blog in blogs) + { + Assert.IsNotType(blog); + } + + var serialized = Newtonsoft.Json.JsonConvert.SerializeObject( + blogs, new Newtonsoft.Json.JsonSerializerSettings + { + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, + Formatting = Newtonsoft.Json.Formatting.Indented + }); + + Assert.Equal(@"[ + { + ""Writer"": { + ""FirstName"": ""firstNameWriter0"", + ""LastName"": ""lastNameWriter0"" + }, + ""Reader"": { + ""FirstName"": ""firstNameReader0"", + ""LastName"": ""lastNameReader0"" + }, + ""Host"": { + ""HostName"": ""127.0.0.1"" + }, + ""Id"": 1 + }, + { + ""Writer"": { + ""FirstName"": ""firstNameWriter1"", + ""LastName"": ""lastNameWriter1"" + }, + ""Reader"": { + ""FirstName"": ""firstNameReader1"", + ""LastName"": ""lastNameReader1"" + }, + ""Host"": { + ""HostName"": ""127.0.0.2"" + }, + ""Id"": 2 + }, + { + ""Writer"": { + ""FirstName"": ""firstNameWriter2"", + ""LastName"": ""lastNameWriter2"" + }, + ""Reader"": { + ""FirstName"": ""firstNameReader2"", + ""LastName"": ""lastNameReader2"" + }, + ""Host"": { + ""HostName"": ""127.0.0.3"" + }, + ""Id"": 3 + } +]", serialized, ignoreLineEndingDifferences: true); + + var newBlogs = Newtonsoft.Json.JsonConvert.DeserializeObject>(serialized); + + VerifyBlogs(newBlogs); + foreach (var blog in newBlogs) + { + Assert.IsType(blog); + } + +#if NETCOREAPP5_0 + var options = new JsonSerializerOptions { ReferenceHandler = ReferenceHandler.Preserve, WriteIndented = true }; + + serialized = JsonSerializer.Serialize(blogs, options); + + Assert.Equal(@"{ + ""$id"": ""1"", + ""$values"": [ + { + ""$id"": ""2"", + ""Id"": 1, + ""Writer"": { + ""$id"": ""3"", + ""FirstName"": ""firstNameWriter0"", + ""LastName"": ""lastNameWriter0"" + }, + ""Reader"": { + ""$id"": ""4"", + ""FirstName"": ""firstNameReader0"", + ""LastName"": ""lastNameReader0"" + }, + ""Host"": { + ""$id"": ""5"", + ""HostName"": ""127.0.0.1"" + } + }, + { + ""$id"": ""6"", + ""Id"": 2, + ""Writer"": { + ""$id"": ""7"", + ""FirstName"": ""firstNameWriter1"", + ""LastName"": ""lastNameWriter1"" + }, + ""Reader"": { + ""$id"": ""8"", + ""FirstName"": ""firstNameReader1"", + ""LastName"": ""lastNameReader1"" + }, + ""Host"": { + ""$id"": ""9"", + ""HostName"": ""127.0.0.2"" + } + }, + { + ""$id"": ""10"", + ""Id"": 3, + ""Writer"": { + ""$id"": ""11"", + ""FirstName"": ""firstNameWriter2"", + ""LastName"": ""lastNameWriter2"" + }, + ""Reader"": { + ""$id"": ""12"", + ""FirstName"": ""firstNameReader2"", + ""LastName"": ""lastNameReader2"" + }, + ""Host"": { + ""$id"": ""13"", + ""HostName"": ""127.0.0.3"" + } + } + ] +}", serialized, ignoreLineEndingDifferences: true); + + newBlogs = JsonSerializer.Deserialize>(serialized, options); + Assert.IsType>(newBlogs); + + foreach (var blog in newBlogs) + { + Assert.IsType(blog); + } + VerifyBlogs(newBlogs); +#endif + } + [ConditionalFact] public virtual void Lazy_loading_finds_correct_entity_type_with_already_loaded_owned_types() { diff --git a/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs index 128cb78bdec..251b0eb7187 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text.Json; -using System.Text.Json.Serialization; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Internal; @@ -52,52 +50,6 @@ await AssertQuery( new ExpectedInclude(o => o.Customer), new ExpectedInclude(c => c.Orders, "Customer")), entryCount: 919); - - using var context = CreateContext(); - - var queryable = context.Set().Include(o => o.Customer).ThenInclude(c => c.Orders); - var orders = async ? await queryable.ToListAsync() : queryable.ToList(); - - Assert.True(orders.Count > 0); - Assert.True(orders.All(od => od.Customer != null)); - Assert.True(orders.All(od => od.Customer.Orders != null)); - - TestJsonSerialization(useNewtonsoft: false, ignoreLoops: false, writeIndented: false); - TestJsonSerialization(useNewtonsoft: false, ignoreLoops: false, writeIndented: true); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: true, writeIndented: false); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: true, writeIndented: true); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: false, writeIndented: false); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: false, writeIndented: true); - - void TestJsonSerialization(bool useNewtonsoft, bool ignoreLoops, bool writeIndented) - { - var ordersAgain = useNewtonsoft - ? RoundtripThroughNewtonsoftJson(orders, ignoreLoops, writeIndented) - : RoundtripThroughBclJson(orders, ignoreLoops, writeIndented); - - var ordersMap = ignoreLoops ? null : new Dictionary(); - var customersMap = ignoreLoops ? null : new Dictionary(); - - foreach (var order in ordersAgain) - { - VerifyOrder(context, order, ordersMap); - - var customer = order.Customer; - Assert.Equal(order.CustomerID, customer.CustomerID); - - VerifyCustomer(context, customer, customersMap); - - foreach (var orderAgain in customer.Orders) - { - VerifyOrder(context, orderAgain, ordersMap); - - if (!ignoreLoops) - { - Assert.Same(customer, orderAgain.Customer); - } - } - } - } } [ConditionalTheory] @@ -888,51 +840,6 @@ await AssertQuery( ss => ss.Set().Include(o => o.Order), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(od => od.Order)), entryCount: 2985); - - using var context = CreateContext(); - - var queryable = context.Set().Include(o => o.Customer).Include(o => o.OrderDetails); - var orders = async ? await queryable.ToListAsync() : queryable.ToList(); - - Assert.Equal(830, orders.Count); - - TestJsonSerialization(useNewtonsoft: false, ignoreLoops: false, writeIndented: false); - TestJsonSerialization(useNewtonsoft: false, ignoreLoops: false, writeIndented: true); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: true, writeIndented: false); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: true, writeIndented: true); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: false, writeIndented: false); - TestJsonSerialization(useNewtonsoft: true, ignoreLoops: false, writeIndented: true); - - void TestJsonSerialization(bool useNewtonsoft, bool ignoreLoops, bool writeIndented) - { - var ordersAgain = useNewtonsoft - ? RoundtripThroughNewtonsoftJson(orders, ignoreLoops, writeIndented) - : RoundtripThroughBclJson(orders, ignoreLoops, writeIndented); - - var ordersMap = ignoreLoops ? null : new Dictionary(); - var ordersDetailsMap = ignoreLoops ? null : new Dictionary<(int, int), OrderDetail>(); - var customersMap = ignoreLoops ? null : new Dictionary(); - - foreach (var order in ordersAgain) - { - VerifyOrder(context, order, ordersMap); - - var customer = order.Customer; - Assert.Equal(order.CustomerID, customer.CustomerID); - - VerifyCustomer(context, customer, customersMap); - - foreach (var orderDetail in order.OrderDetails) - { - VerifyOrderDetails(context, orderDetail, ordersDetailsMap); - - if (!ignoreLoops) - { - Assert.Same(order, orderDetail.Order); - } - } - } - } } [ConditionalTheory] @@ -1603,146 +1510,6 @@ orderby e.EmployeeID private static string ClientMethod(Employee e) => e.FirstName + " reports to " + e.Manager.FirstName; - private static T RoundtripThroughBclJson(T collection, bool ignoreLoops, bool writeIndented, int maxDepth = 64) - { - Assert.False(ignoreLoops, "BCL doesn't support ignoring loops."); - -#if NETCOREAPP5_0 - var options = new JsonSerializerOptions - { - ReferenceHandler = ReferenceHandler.Preserve, - WriteIndented = writeIndented, - MaxDepth = maxDepth - }; - - return JsonSerializer.Deserialize(JsonSerializer.Serialize(collection, options), options); -#else - return collection; -#endif - } - - private static T RoundtripThroughNewtonsoftJson(T collection, bool ignoreLoops, bool writeIndented) - { - var options = new Newtonsoft.Json.JsonSerializerSettings - { - PreserveReferencesHandling = ignoreLoops - ? Newtonsoft.Json.PreserveReferencesHandling.None - : Newtonsoft.Json.PreserveReferencesHandling.All, - ReferenceLoopHandling = ignoreLoops - ? Newtonsoft.Json.ReferenceLoopHandling.Ignore - : Newtonsoft.Json.ReferenceLoopHandling.Error, - EqualityComparer = LegacyReferenceEqualityComparer.Instance, - Formatting = writeIndented - ? Newtonsoft.Json.Formatting.Indented - : Newtonsoft.Json.Formatting.None - }; - - var serializeObject = Newtonsoft.Json.JsonConvert.SerializeObject(collection, options); - - return Newtonsoft.Json.JsonConvert.DeserializeObject(serializeObject); - } - - private static void VerifyCustomer(NorthwindContext context, Customer customer, Dictionary customersMap) - { - var trackedCustomer = context.Customers.Find(customer.CustomerID); - Assert.Equal(trackedCustomer.Address, customer.Address); - Assert.Equal(trackedCustomer.City, customer.City); - Assert.Equal(trackedCustomer.Country, customer.Country); - Assert.Equal(trackedCustomer.Fax, customer.Fax); - Assert.Equal(trackedCustomer.Phone, customer.Phone); - Assert.Equal(trackedCustomer.Region, customer.Region); - Assert.Equal(trackedCustomer.CompanyName, customer.CompanyName); - Assert.Equal(trackedCustomer.ContactName, customer.ContactName); - Assert.Equal(trackedCustomer.ContactTitle, customer.ContactTitle); - Assert.Equal(trackedCustomer.IsLondon, customer.IsLondon); - Assert.Equal(trackedCustomer.PostalCode, customer.PostalCode); - Assert.Equal(trackedCustomer.CustomerID, customer.CustomerID); - - if (customersMap != null) - { - if (customersMap.TryGetValue(customer.CustomerID, out var mappedCustomer)) - { - Assert.Same(customer, mappedCustomer); - } - - customersMap[customer.CustomerID] = customer; - } - } - - private static void VerifyOrder(NorthwindContext context, Order order, IDictionary ordersMap) - { - var trackedOrder = context.Orders.Find(order.OrderID); - Assert.Equal(trackedOrder.Freight, order.Freight); - Assert.Equal(trackedOrder.OrderDate, order.OrderDate); - Assert.Equal(trackedOrder.RequiredDate, order.RequiredDate); - Assert.Equal(trackedOrder.ShipAddress, order.ShipAddress); - Assert.Equal(trackedOrder.ShipCity, order.ShipCity); - Assert.Equal(trackedOrder.ShipCountry, order.ShipCountry); - Assert.Equal(trackedOrder.ShipName, order.ShipName); - Assert.Equal(trackedOrder.ShippedDate, order.ShippedDate); - Assert.Equal(trackedOrder.ShipRegion, order.ShipRegion); - Assert.Equal(trackedOrder.ShipVia, order.ShipVia); - Assert.Equal(trackedOrder.CustomerID, order.CustomerID); - Assert.Equal(trackedOrder.EmployeeID, order.EmployeeID); - Assert.Equal(trackedOrder.OrderID, order.OrderID); - Assert.Equal(trackedOrder.ShipPostalCode, order.ShipPostalCode); - - if (ordersMap != null) - { - if (ordersMap.TryGetValue(order.OrderID, out var mappedOrder)) - { - Assert.Same(order, mappedOrder); - } - - ordersMap[order.OrderID] = order; - } - } - - private static void VerifyOrderDetails(NorthwindContext context, OrderDetail orderDetail, IDictionary<(int, int), OrderDetail> orderDetailsMap) - { - var trackedOrderDetail = context.OrderDetails.Find(orderDetail.OrderID, orderDetail.ProductID); - Assert.Equal(trackedOrderDetail.Discount, orderDetail.Discount); - Assert.Equal(trackedOrderDetail.Quantity, orderDetail.Quantity); - Assert.Equal(trackedOrderDetail.UnitPrice, orderDetail.UnitPrice); - Assert.Equal(trackedOrderDetail.OrderID, orderDetail.OrderID); - Assert.Equal(trackedOrderDetail.ProductID, orderDetail.ProductID); - - if (orderDetailsMap != null) - { - if (orderDetailsMap.TryGetValue((orderDetail.OrderID, orderDetail.ProductID), out var mappedOrderDetail)) - { - Assert.Same(orderDetail, mappedOrderDetail); - } - - orderDetailsMap[(orderDetail.OrderID, orderDetail.ProductID)] = orderDetail; - } - } - - private static void VerifyProduct(NorthwindContext context, Product product, IDictionary productsMap) - { - var trackedProduct = context.Products.Find(product.ProductID); - Assert.Equal(trackedProduct.Discontinued, product.Discontinued); - Assert.Equal(trackedProduct.ProductName, product.ProductName); - Assert.Equal(trackedProduct.ReorderLevel, product.ReorderLevel); - Assert.Equal(trackedProduct.UnitPrice, product.UnitPrice); - Assert.Equal(trackedProduct.CategoryID, product.CategoryID); - Assert.Equal(trackedProduct.ProductID, product.ProductID); - Assert.Equal(trackedProduct.QuantityPerUnit, product.QuantityPerUnit); - Assert.Equal(trackedProduct.SupplierID, product.SupplierID); - Assert.Equal(trackedProduct.UnitsInStock, product.UnitsInStock); - Assert.Equal(trackedProduct.UnitsOnOrder, product.UnitsOnOrder); - - if (productsMap != null) - { - if (productsMap.TryGetValue(product.ProductID, out var mappedProduct)) - { - Assert.Same(product, mappedProduct); - } - - productsMap[product.ProductID] = product; - } - } - // Issue#18672 [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/SerializationTestBase.cs b/test/EFCore.Specification.Tests/SerializationTestBase.cs new file mode 100644 index 00000000000..63b14711a55 --- /dev/null +++ b/test/EFCore.Specification.Tests/SerializationTestBase.cs @@ -0,0 +1,156 @@ +// 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 System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using Microsoft.EntityFrameworkCore.Internal; +using Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel; +using Xunit; + +namespace Microsoft.EntityFrameworkCore +{ + public abstract class SerializationTestBase : IClassFixture + where TFixture : F1FixtureBase, new() + { + protected SerializationTestBase(TFixture fixture) => Fixture = fixture; + + protected TFixture Fixture { get; } + + [ConditionalTheory] + [InlineData(false, false, false)] + [InlineData(false, false, true)] + [InlineData(true, true, false)] + [InlineData(true, true, true)] + [InlineData(true, false, false)] + [InlineData(true, false, true)] + public virtual void Can_round_trip_through_JSON(bool useNewtonsoft, bool ignoreLoops, bool writeIndented) + { + using var context = Fixture.CreateContext(); + + var teams = context.Teams.Include(e => e.Drivers) + .Include(e => e.Engine).ThenInclude(e => e.EngineSupplier) + .ToList(); + + Assert.Equal(12, teams.Count); + Assert.Equal(42, teams.SelectMany(e => e.Drivers).Count()); + Assert.True(teams.All(e => e.Engine != null)); + Assert.True(teams.All(e => e.Engine.EngineSupplier != null)); + + var teamsAgain = useNewtonsoft + ? RoundtripThroughNewtonsoftJson(teams, ignoreLoops, writeIndented) + : RoundtripThroughBclJson(teams, ignoreLoops, writeIndented); + + var teamsMap = ignoreLoops ? null : new Dictionary(); + var enginesMap = ignoreLoops ? null : new Dictionary(); + var engineSupplierMap = ignoreLoops ? null : new Dictionary(); + + foreach (var team in teamsAgain) + { + VerifyTeam(context, team, teamsMap); + VerifyEngine(context, team.Engine, enginesMap); + VerifyEngineSupplier(context, team.Engine.EngineSupplier, engineSupplierMap); + } + } + + private static void VerifyTeam(F1Context context, Team team, IDictionary teamsMap) + { + var trackedTeam = context.Teams.Find(team.Id); + Assert.Equal(trackedTeam.Constructor, team.Constructor); + Assert.Equal(trackedTeam.Name, team.Name); + Assert.Equal(trackedTeam.Poles, team.Poles); + Assert.Equal(trackedTeam.Principal, team.Principal); + Assert.Equal(trackedTeam.Races, team.Races); + Assert.Equal(trackedTeam.Tire, team.Tire); + Assert.Equal(trackedTeam.Victories, team.Victories); + Assert.Equal(trackedTeam.ConstructorsChampionships, team.ConstructorsChampionships); + Assert.Equal(trackedTeam.DriversChampionships, team.DriversChampionships); + Assert.Equal(trackedTeam.FastestLaps, team.FastestLaps); + + if (teamsMap != null) + { + if (teamsMap.TryGetValue(team.Id, out var mappedTeam)) + { + Assert.Same(team, mappedTeam); + } + + teamsMap[team.Id] = team; + } + } + + private static void VerifyEngine(F1Context context, Engine engine, IDictionary enginesMap) + { + var trackedEngine = context.Engines.Find(engine.Id); + Assert.Equal(trackedEngine.StorageLocation.Latitude, engine.StorageLocation.Latitude); + Assert.Equal(trackedEngine.StorageLocation.Longitude, engine.StorageLocation.Longitude); + Assert.Equal(trackedEngine.Name, engine.Name); + + if (enginesMap != null) + { + if (enginesMap.TryGetValue(engine.Id, out var mappedEngine)) + { + Assert.Same(engine, mappedEngine); + } + + enginesMap[engine.Id] = engine; + } + } + + private static void VerifyEngineSupplier( + F1Context context, EngineSupplier engineSupplier, IDictionary engineSupplierMap) + { + var trackedEngineSupplier = context.EngineSuppliers.Find(engineSupplier.Id); + Assert.Equal(trackedEngineSupplier.Name, engineSupplier.Name); + + if (engineSupplierMap != null) + { + if (engineSupplierMap.TryGetValue(engineSupplier.Id, out var mappedEngineSupplier)) + { + Assert.Same(engineSupplier, mappedEngineSupplier); + } + + engineSupplierMap[engineSupplier.Id] = engineSupplier; + } + } + + private static T RoundtripThroughBclJson(T collection, bool ignoreLoops, bool writeIndented, int maxDepth = 64) + { + Assert.False(ignoreLoops, "BCL doesn't support ignoring loops."); + +#if NETCOREAPP5_0 + var options = new JsonSerializerOptions + { + ReferenceHandler = ReferenceHandler.Preserve, + WriteIndented = writeIndented, + MaxDepth = maxDepth + }; + + return JsonSerializer.Deserialize(JsonSerializer.Serialize(collection, options), options); +#else + return collection; +#endif + } + + private static T RoundtripThroughNewtonsoftJson(T collection, bool ignoreLoops, bool writeIndented) + { + var options = new Newtonsoft.Json.JsonSerializerSettings + { + PreserveReferencesHandling = ignoreLoops + ? Newtonsoft.Json.PreserveReferencesHandling.None + : Newtonsoft.Json.PreserveReferencesHandling.All, + ReferenceLoopHandling = ignoreLoops + ? Newtonsoft.Json.ReferenceLoopHandling.Ignore + : Newtonsoft.Json.ReferenceLoopHandling.Error, + EqualityComparer = LegacyReferenceEqualityComparer.Instance, + Formatting = writeIndented + ? Newtonsoft.Json.Formatting.Indented + : Newtonsoft.Json.Formatting.None + }; + + var serializeObject = Newtonsoft.Json.JsonConvert.SerializeObject(collection, options); + + return Newtonsoft.Json.JsonConvert.DeserializeObject(serializeObject); + } + } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index 75755655798..9666cc8f70f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -728,13 +728,7 @@ public override async Task Include_reference_alias_generation(bool async) AssertSql( @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM [Order Details] AS [o] -INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID]", - // - @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] -FROM [Orders] AS [o] -LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -LEFT JOIN [Order Details] AS [o0] ON [o].[OrderID] = [o0].[OrderID] -ORDER BY [o].[OrderID], [c].[CustomerID], [o0].[OrderID], [o0].[ProductID]"); +INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID]"); } public override async Task Include_duplicate_reference(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs index 1e35467f0ea..3d1d2281103 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs @@ -1063,13 +1063,7 @@ public override async Task Include_reference_alias_generation(bool async) AssertSql( @"SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate] FROM [Order Details] AS [o] -INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID]", - // - @"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] -FROM [Orders] AS [o] -LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID] -LEFT JOIN [Order Details] AS [o0] ON [o].[OrderID] = [o0].[OrderID] -ORDER BY [o].[OrderID], [c].[CustomerID], [o0].[OrderID], [o0].[ProductID]"); +INNER JOIN [Orders] AS [o0] ON [o].[OrderID] = [o0].[OrderID]"); } public override async Task Include_duplicate_reference(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/SerializationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/SerializationSqlServerTest.cs new file mode 100644 index 00000000000..fc2ed580be7 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/SerializationSqlServerTest.cs @@ -0,0 +1,13 @@ +// 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. + +namespace Microsoft.EntityFrameworkCore +{ + public class SerializationSqlServerTest : SerializationTestBase + { + public SerializationSqlServerTest(F1SqlServerFixture fixture) + : base(fixture) + { + } + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/SerializationSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/SerializationSqliteTest.cs new file mode 100644 index 00000000000..c46351122fa --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/SerializationSqliteTest.cs @@ -0,0 +1,13 @@ +// 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. + +namespace Microsoft.EntityFrameworkCore +{ + public class SerializationSqliteTest : SerializationTestBase + { + public SerializationSqliteTest(F1SqliteFixture fixture) + : base(fixture) + { + } + } +}