-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable OptimisticConcurrencyTest on Cosmos
Fixes #22165
- Loading branch information
1 parent
319607c
commit b8293b4
Showing
15 changed files
with
284 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// 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.ConcurrencyModel; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
// ReSharper disable InconsistentNaming | ||
namespace Microsoft.EntityFrameworkCore.Cosmos | ||
{ | ||
public class F1CosmosFixture : F1FixtureBase | ||
{ | ||
protected override ITestStoreFactory TestStoreFactory | ||
=> CosmosTestStoreFactory.Instance; | ||
|
||
public override TestHelpers TestHelpers | ||
=> CosmosTestHelpers.Instance; | ||
|
||
protected override void BuildModelExternal(ModelBuilder modelBuilder) | ||
{ | ||
base.BuildModelExternal(modelBuilder); | ||
|
||
modelBuilder.Entity<Engine>( | ||
b => | ||
{ | ||
b.Property(e => e.EngineSupplierId).IsConcurrencyToken(false); | ||
b.Property(e => e.Name).IsConcurrencyToken(false); | ||
b.OwnsOne( | ||
e => e.StorageLocation, lb => | ||
{ | ||
lb.Property(l => l.Latitude).IsConcurrencyToken(false); | ||
lb.Property(l => l.Longitude).IsConcurrencyToken(false); | ||
}); | ||
}); | ||
|
||
modelBuilder.Entity<Chassis>().Property<string>("Version").IsETagConcurrency(); | ||
modelBuilder.Entity<Driver>().Property<string>("Version").IsETagConcurrency(); | ||
modelBuilder.Entity<Team>().Property<string>("Version").IsETagConcurrency(); | ||
|
||
modelBuilder.Entity<Sponsor>( | ||
eb => | ||
{ | ||
eb.Property<string>("Version").IsETagConcurrency(); | ||
eb.Property<int?>(Sponsor.ClientTokenPropertyName).IsConcurrencyToken(false); | ||
}); | ||
modelBuilder.Entity<TitleSponsor>() | ||
.OwnsOne( | ||
s => s.Details, eb => | ||
{ | ||
eb.Property<string>("Version").IsETagConcurrency(); | ||
eb.Property<int?>(Sponsor.ClientTokenPropertyName); | ||
}); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
test/EFCore.Cosmos.FunctionalTests/OptimisticConcurrencyCosmosTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 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; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
|
||
// ReSharper disable InconsistentNaming | ||
namespace Microsoft.EntityFrameworkCore.Cosmos | ||
{ | ||
public class OptimisticConcurrencyCosmosTest : OptimisticConcurrencyTestBase<F1CosmosFixture> | ||
{ | ||
public OptimisticConcurrencyCosmosTest(F1CosmosFixture fixture) | ||
: base(fixture) | ||
{ | ||
fixture.Reseed(); | ||
} | ||
|
||
// Non-persisted property in query | ||
// Issue #17670 | ||
public override Task Calling_GetDatabaseValues_on_owned_entity_works(bool async) | ||
=> Task.CompletedTask; | ||
|
||
public override Task Calling_Reload_on_owned_entity_works(bool async) | ||
=> Task.CompletedTask; | ||
|
||
// Only ETag properties can be used as concurrency tokens | ||
public override Task Concurrency_issue_where_the_FK_is_the_concurrency_token_can_be_handled() | ||
=> Task.CompletedTask; | ||
|
||
public override void Nullable_client_side_concurrency_token_can_be_used() | ||
{ | ||
} | ||
|
||
// ETag concurrency doesn't work after an item was deleted | ||
public override Task Deleting_the_same_entity_twice_results_in_DbUpdateConcurrencyException() | ||
=> Task.CompletedTask; | ||
|
||
public override Task Deleting_then_updating_the_same_entity_results_in_DbUpdateConcurrencyException() | ||
=> Task.CompletedTask; | ||
|
||
public override Task Deleting_then_updating_the_same_entity_results_in_DbUpdateConcurrencyException_which_can_be_resolved_with_store_values() | ||
=> Task.CompletedTask; | ||
|
||
protected override IDbContextTransaction BeginTransaction(DatabaseFacade facade) => new FakeDbContextTransaction(); | ||
|
||
private class FakeDbContextTransaction : IDbContextTransaction | ||
{ | ||
public Guid TransactionId => new Guid(); | ||
|
||
public void Commit() | ||
{ | ||
} | ||
|
||
public Task CommitAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
|
||
public ValueTask DisposeAsync() => default; | ||
|
||
public void Rollback() | ||
{ | ||
} | ||
|
||
public Task RollbackAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.