Files
2023-07-11 10:00:30 +08:00

48 lines
1.4 KiB
C#

using System;
using System.Threading.Tasks;
using Util.Data.Sql;
using Util.Tests.Configs;
using Xunit;
namespace Util.Data.Dapper.Tests.SqlQuery;
/// <summary>
/// Sql Server Sql查询对象测试 - 判断是否存在测试
/// </summary>
public partial class SqlServerSqlQueryTest {
/// <summary>
/// 测试判断是否存在 - 存在
/// </summary>
[Fact]
public void TestExecuteExists_1() {
var result = _sqlQuery.From( "Products.Product" ).Where( "ProductId", TestConfig.Id ).ExecuteExists();
Assert.True( result );
}
/// <summary>
/// 测试判断是否存在 - 不存在
/// </summary>
[Fact]
public void TestExecuteExists_2() {
var result = _sqlQuery.From( "Products.Product" ).Where( "ProductId", Guid.NewGuid() ).ExecuteExists();
Assert.False( result );
}
/// <summary>
/// 测试判断是否存在 - 存在
/// </summary>
[Fact]
public async Task TestExecuteExistsAsync_1() {
var result = await _sqlQuery.From( "Products.Product" ).Where( "ProductId", TestConfig.Id ).ExecuteExistsAsync();
Assert.True( result );
}
/// <summary>
/// 测试判断是否存在 - 不存在
/// </summary>
[Fact]
public async Task TestExecuteExistsAsync_2() {
var result = await _sqlQuery.From( "Products.Product" ).Where( "ProductId", Guid.NewGuid() ).ExecuteExistsAsync();
Assert.False( result );
}
}