public override SqlCeTestStore CreateTestStore() => SqlCeTestStore.GetOrCreateShared(DatabaseName, () => { var options = new DbContextOptionsBuilder(_options) .UseSqlCe(_connectionString, b => b.ApplyConfiguration()) .Options; using (var context = new DataAnnotationContext(options)) { context.Database.EnsureClean(); DataAnnotationModelInitializer.Seed(context); } });
public override void TimestampAttribute_throws_if_value_in_database_changed() { using (var context = CreateContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); DataAnnotationModelInitializer.Seed(context); Assert.True(context.Model.FindEntityType(typeof(Two)).FindProperty("Timestamp").IsConcurrencyToken); } base.TimestampAttribute_throws_if_value_in_database_changed(); // Not validating SQL because not significantly different from other tests and // row version value is not stable. }
public override void ConcurrencyCheckAttribute_throws_if_value_in_database_changed() { //TODO ErikEJ Why is fixture not running? using (var context = CreateContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); DataAnnotationModelInitializer.Seed(context); Fixture.TestSqlLoggerFactory.Clear(); } base.ConcurrencyCheckAttribute_throws_if_value_in_database_changed(); Assert.Equal(@"SELECT TOP(1) [r].[UniqueNo], [r].[MaxLengthProperty], [r].[Name], [r].[RowVersion] FROM [Sample] AS [r] WHERE [r].[UniqueNo] = 1 SELECT TOP(1) [r].[UniqueNo], [r].[MaxLengthProperty], [r].[Name], [r].[RowVersion] FROM [Sample] AS [r] WHERE [r].[UniqueNo] = 1 @p2: 1 @p0: ModifiedData (Nullable = false) (Size = 4000) @p1: 00000000-0000-0000-0003-000000000001 @p3: 00000001-0000-0000-0000-000000000001 UPDATE [Sample] SET [Name] = @p0, [RowVersion] = @p1 WHERE [UniqueNo] = @p2 AND [RowVersion] = @p3 @p2: 1 @p0: ChangedData (Nullable = false) (Size = 4000) @p1: 00000000-0000-0000-0002-000000000001 @p3: 00000001-0000-0000-0000-000000000001 UPDATE [Sample] SET [Name] = @p0, [RowVersion] = @p1 WHERE [UniqueNo] = @p2 AND [RowVersion] = @p3", Sql); }