From 6cb109c56eee3b04c2c842aea7f851e1f13352e2 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 9 Feb 2020 23:11:22 -0500 Subject: [PATCH] Adds tests for Cosmos on translating binary checked operations to their unchecked equivalents --- .../NorthwindMiscellaneousQueryCosmosTest.cs | 10 ++++++++++ .../NorthwindMiscellaneousQueryTestBase.cs | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index 36815fa328d..9091ebd94db 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -4057,6 +4057,16 @@ public override Task Anonymous_projection_skip_take_empty_collection_FirstOrDefa return base.Anonymous_projection_skip_take_empty_collection_FirstOrDefault(async); } + public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) + { + await base.Checked_context_with_addition_does_not_fail(isAsync); + + AssertSql(@"SELECT c +FROM root c +WHERE ((c[""Discriminator""] = ""OrderDetail"") AND ((c[""Quantity""] + 1) = 5)) +ORDER BY c[""OrderID""]"); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index 63bfed90b3d..01a493c196f 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -5691,5 +5691,22 @@ public virtual Task Anonymous_projection_skip_take_empty_collection_FirstOrDefau .Take(1) .Select(e => e.Customer.Orders.FirstOrDefault())); } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Checked_context_with_addition_does_not_fail(bool isAsync) + { + checked + { + return AssertQuery( + isAsync, + ss => ss.Set() + .Where(w => w.Quantity + 1 == 5) + .OrderBy(o => o.OrderID), + entryCount: 55, + assertOrder: true, + elementAsserter: (e, a) => { AssertEqual(e, a); }); + } + } } }