Skip to content

Commit afd9fe8

Browse files
author
Brandt
committed
Added new test
1 parent 4c79588 commit afd9fe8

File tree

2 files changed

+14
-57
lines changed

2 files changed

+14
-57
lines changed

readme.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,6 @@ else
9191
select cast(@timeStamp as varchar) + '-' + cast(@changeTracking as varchar)
9292
```
9393
<sup><a href='/src/Delta/DeltaExtensions_Sql.cs#L46-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-SqlServerTimestamp' title='Start of snippet'>anchor</a></sup>
94-
<a id='snippet-SqlServerTimestamp-1'></a>
95-
```cs
96-
declare @changeTracking bigint = change_tracking_current_version();
97-
declare @timeStamp bigint = convert(bigint, @@dbts);
98-
99-
if (@changeTracking is null)
100-
select cast(@timeStamp as varchar)
101-
else
102-
select cast(@timeStamp as varchar) + '-' + cast(@changeTracking as varchar)
103-
```
104-
<sup><a href='/src/DeltaTests/Usage.cs#L71-L79' title='Snippet source file'>snippet source</a> | <a href='#snippet-SqlServerTimestamp-1' title='Start of snippet'>anchor</a></sup>
10594
<!-- endSnippet -->
10695

10796

@@ -346,7 +335,7 @@ var application = webApplicationBuilder.Build();
346335
application.UseDelta(
347336
getConnection: httpContext => httpContext.RequestServices.GetRequiredService<SqlConnection>());
348337
```
349-
<sup><a href='/src/DeltaTests/Usage.cs#L295-L301' title='Snippet source file'>snippet source</a> | <a href='#snippet-CustomDiscoveryConnection' title='Start of snippet'>anchor</a></sup>
338+
<sup><a href='/src/DeltaTests/Usage.cs#L252-L258' title='Snippet source file'>snippet source</a> | <a href='#snippet-CustomDiscoveryConnection' title='Start of snippet'>anchor</a></sup>
350339
<!-- endSnippet -->
351340

352341
To use custom connection and transaction discovery:
@@ -364,7 +353,7 @@ webApplication.UseDelta(
364353
return new(sqlConnection, sqlTransaction);
365354
});
366355
```
367-
<sup><a href='/src/DeltaTests/Usage.cs#L306-L318' title='Snippet source file'>snippet source</a> | <a href='#snippet-CustomDiscoveryConnectionAndTransaction' title='Start of snippet'>anchor</a></sup>
356+
<sup><a href='/src/DeltaTests/Usage.cs#L263-L275' title='Snippet source file'>snippet source</a> | <a href='#snippet-CustomDiscoveryConnectionAndTransaction' title='Start of snippet'>anchor</a></sup>
368357
<!-- endSnippet -->
369358

370359

@@ -551,7 +540,7 @@ Nuget: [Delta.SqlServer](https://www.nuget.org/packages/Delta.SqlServer)
551540
```cs
552541
var timeStamp = await sqlConnection.GetLastTimeStamp();
553542
```
554-
<sup><a href='/src/DeltaTests/Usage.cs#L134-L138' title='Snippet source file'>snippet source</a> | <a href='#snippet-GetLastTimeStampSqlConnection' title='Start of snippet'>anchor</a></sup>
543+
<sup><a href='/src/DeltaTests/Usage.cs#L91-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-GetLastTimeStampSqlConnection' title='Start of snippet'>anchor</a></sup>
555544
<!-- endSnippet -->
556545

557546

@@ -579,7 +568,7 @@ foreach (var db in trackedDatabases)
579568
Trace.WriteLine(db);
580569
}
581570
```
582-
<sup><a href='/src/DeltaTests/Usage.cs#L193-L201' title='Snippet source file'>snippet source</a> | <a href='#snippet-GetDatabasesWithTracking' title='Start of snippet'>anchor</a></sup>
571+
<sup><a href='/src/DeltaTests/Usage.cs#L150-L158' title='Snippet source file'>snippet source</a> | <a href='#snippet-GetDatabasesWithTracking' title='Start of snippet'>anchor</a></sup>
583572
<!-- endSnippet -->
584573

585574
Uses the following SQL:
@@ -609,7 +598,7 @@ foreach (var db in trackedTables)
609598
Trace.WriteLine(db);
610599
}
611600
```
612-
<sup><a href='/src/DeltaTests/Usage.cs#L219-L227' title='Snippet source file'>snippet source</a> | <a href='#snippet-GetTrackedTables' title='Start of snippet'>anchor</a></sup>
601+
<sup><a href='/src/DeltaTests/Usage.cs#L176-L184' title='Snippet source file'>snippet source</a> | <a href='#snippet-GetTrackedTables' title='Start of snippet'>anchor</a></sup>
613602
<!-- endSnippet -->
614603

615604
Uses the following SQL:
@@ -634,7 +623,7 @@ Determine if change tracking is enabled for a database.
634623
```cs
635624
var isTrackingEnabled = await sqlConnection.IsTrackingEnabled();
636625
```
637-
<sup><a href='/src/DeltaTests/Usage.cs#L284-L288' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsTrackingEnabled' title='Start of snippet'>anchor</a></sup>
626+
<sup><a href='/src/DeltaTests/Usage.cs#L241-L245' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsTrackingEnabled' title='Start of snippet'>anchor</a></sup>
638627
<!-- endSnippet -->
639628

640629
Uses the following SQL:
@@ -661,7 +650,7 @@ Enable change tracking for a database.
661650
```cs
662651
await sqlConnection.EnableTracking();
663652
```
664-
<sup><a href='/src/DeltaTests/Usage.cs#L278-L282' title='Snippet source file'>snippet source</a> | <a href='#snippet-EnableTracking' title='Start of snippet'>anchor</a></sup>
653+
<sup><a href='/src/DeltaTests/Usage.cs#L235-L239' title='Snippet source file'>snippet source</a> | <a href='#snippet-EnableTracking' title='Start of snippet'>anchor</a></sup>
665654
<!-- endSnippet -->
666655

667656
Uses the following SQL:
@@ -689,7 +678,7 @@ Disable change tracking for a database and all tables within that database.
689678
```cs
690679
await sqlConnection.DisableTracking();
691680
```
692-
<sup><a href='/src/DeltaTests/Usage.cs#L263-L267' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableTracking' title='Start of snippet'>anchor</a></sup>
681+
<sup><a href='/src/DeltaTests/Usage.cs#L220-L224' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableTracking' title='Start of snippet'>anchor</a></sup>
693682
<!-- endSnippet -->
694683

695684
Uses the following SQL:
@@ -726,7 +715,7 @@ Enables change tracking for all tables listed, and disables change tracking for
726715
```cs
727716
await sqlConnection.SetTrackedTables(["Companies"]);
728717
```
729-
<sup><a href='/src/DeltaTests/Usage.cs#L213-L217' title='Snippet source file'>snippet source</a> | <a href='#snippet-SetTrackedTables' title='Start of snippet'>anchor</a></sup>
718+
<sup><a href='/src/DeltaTests/Usage.cs#L170-L174' title='Snippet source file'>snippet source</a> | <a href='#snippet-SetTrackedTables' title='Start of snippet'>anchor</a></sup>
730719
<!-- endSnippet -->
731720

732721
Uses the following SQL:

src/DeltaTests/Usage.cs

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,63 +54,31 @@ insert into [Companies] (Id, Content)
5454
public async Task LastTimeStampRowVersionOnDelete()
5555
{
5656
await using var database = await LocalDb();
57-
using var connection = database.Connection;
57+
await using var connection = database.Connection;
5858
await connection.EnableTracking();
5959

60-
var theCompanyGuid = Guid.NewGuid();
60+
var companyGuid = Guid.NewGuid();
6161
await using var addDataCommand = connection.CreateCommand();
6262
addDataCommand.CommandText =
6363
$"""
6464
insert into [Companies] (Id, Content)
65-
values ('{theCompanyGuid}', 'The company')
65+
values ('{companyGuid}', 'The company')
6666
""";
6767
await addDataCommand.ExecuteNonQueryAsync();
6868

69-
await using var checkCommand = connection.CreateCommand();
70-
await using (var temp = await checkCommand.ExecuteReaderAsync())
71-
{
72-
if (await temp.ReadAsync())
73-
{
74-
Console.WriteLine($"Current Change Tracking Version: {temp[0]}");
75-
}
76-
}
77-
7869
var timeStamp = await DeltaExtensions.GetLastTimeStamp(connection, null);
79-
80-
await using var firstChangeCommand = connection.CreateCommand();
81-
firstChangeCommand.CommandText = $"SELECT change_tracking_current_version();";
82-
await using (var reader = await firstChangeCommand.ExecuteReaderAsync())
83-
{
84-
if (await reader.ReadAsync())
85-
{
86-
Console.WriteLine($"Current Change Tracking Version: {reader[0]}");
87-
}
88-
}
89-
9070
IsNotEmpty(timeStamp);
9171
IsNotNull(timeStamp);
92-
// Recording.Start();
9372

9473
await using var deleteCommand = connection.CreateCommand();
9574
deleteCommand.CommandText = $"delete From Companies where Id=@deleteId";
96-
deleteCommand.Parameters.AddWithValue("@deleteId", theCompanyGuid);
75+
deleteCommand.Parameters.AddWithValue("@deleteId", companyGuid);
9776
await deleteCommand.ExecuteNonQueryAsync();
9877

9978
var newTimeStamp = await DeltaExtensions.GetLastTimeStamp(connection, null);
100-
await using var secondChangeCommand = connection.CreateCommand();
101-
secondChangeCommand.CommandText = $"SELECT change_tracking_current_version();";
102-
await using (var reader2 = await secondChangeCommand.ExecuteReaderAsync())
103-
{
104-
if (await reader2.ReadAsync())
105-
{
106-
Console.WriteLine($"Current Change Tracking Version: {reader2[0]}");
107-
}
108-
}
109-
11079
IsNotEmpty(newTimeStamp);
11180
IsNotNull(newTimeStamp);
112-
//await Verify(newTimeStamp);
113-
// AreNotEqual(newTimeStamp, timeStamp);
81+
AreNotEqual(newTimeStamp, timeStamp);
11482
}
11583

11684
[Test]

0 commit comments

Comments
 (0)