Skip to content

Commit d97f076

Browse files
committed
Created test for QueryEndpoint.Singe/SingleOrDefault
1 parent 9f12369 commit d97f076

3 files changed

Lines changed: 505 additions & 3 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (C) 2026 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using Xtensive.Core;
7+
8+
namespace Xtensive.Orm.Tests
9+
{
10+
public sealed class QueryExecutionDetector
11+
{
12+
private int dbCommandCounter = 0;
13+
private int queryCounter = 0;
14+
15+
public bool DbCommandsDetected => dbCommandCounter > 0;
16+
public bool QueriesDetected => queryCounter > 0;
17+
18+
public IDisposable Attach(Session session)
19+
{
20+
session.Events.DbCommandExecuted += Events_DbCommandExecuted;
21+
22+
return new Disposable((b) => { session.Events.DbCommandExecuted -= Events_DbCommandExecuted; });
23+
}
24+
25+
public void Reset()
26+
{
27+
dbCommandCounter = 0;
28+
queryCounter = 0;
29+
}
30+
31+
private void Events_DbCommandExecuted(object sender, DbCommandEventArgs e) => dbCommandCounter++;
32+
}
33+
}

0 commit comments

Comments
 (0)