wip
This commit is contained in:
parent
f3ab94eff1
commit
31666b4ba0
34 changed files with 140 additions and 83 deletions
|
|
@ -1,7 +1,8 @@
|
|||
using Autofac;
|
||||
using Insight.Database;
|
||||
using PlanTempus.Core.Sql;
|
||||
using PlanTempus.Core.Sql.ConnectionFactory;
|
||||
using PlanTempus.Components.Users.Exceptions;
|
||||
using PlanTempus.Core.Database;
|
||||
using PlanTempus.Core.Database.ConnectionFactory;
|
||||
using Shouldly;
|
||||
|
||||
namespace PlanTempus.X.TDD;
|
||||
|
|
@ -38,8 +39,6 @@ public class PostgresTests : TestFixture
|
|||
{
|
||||
var user = await db.Connection.QuerySqlAsync<string>(
|
||||
"SELECT tablename FROM pg_tables limit 5");
|
||||
|
||||
db.Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -56,8 +55,6 @@ public class PostgresTests : TestFixture
|
|||
{
|
||||
var user = await db.Connection.QuerySqlAsync<string>(
|
||||
"SELECT tablename FROM pg_tables limit 5");
|
||||
|
||||
db.Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -69,7 +66,7 @@ public class PostgresTests : TestFixture
|
|||
public async Task TestForUniqueUserEmail()
|
||||
{
|
||||
using var db = _databaseOperations.CreateScope(nameof(TestForUniqueUserEmail));
|
||||
try
|
||||
// try
|
||||
{
|
||||
var sql = @"
|
||||
INSERT INTO system.users(email, password_hash, security_stamp, email_confirmed,
|
||||
|
|
@ -81,7 +78,7 @@ public class PostgresTests : TestFixture
|
|||
|
||||
var parameters = new
|
||||
{
|
||||
Email = "elon.musk@mars.com",
|
||||
Email = "jarjarbinks22233@mars.com",
|
||||
PasswordHash = "MartianRover2025",
|
||||
SecurityStamp = "MarsOrBust",
|
||||
EmailConfirmed = true,
|
||||
|
|
@ -92,19 +89,18 @@ public class PostgresTests : TestFixture
|
|||
|
||||
var user = await db.Connection.QuerySqlAsync<dynamic>(sql, parameters);
|
||||
|
||||
user.ShouldNotBeNull();
|
||||
// ((string)user.email).ShouldBe("elon.musk@mars.com");
|
||||
// ((bool)user.is_active).ShouldBeTrue();
|
||||
// user.ShouldNotBeNull();
|
||||
|
||||
db.Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
db.Error(ex);
|
||||
//try insert, to test exception
|
||||
var ex = await Should.ThrowAsync<EmailAlreadyRegistreredException>(async () =>
|
||||
await db.Connection.ExecuteAsync(sql, parameters));
|
||||
}
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// db.Error(ex);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestSimpleDatabaseOperation()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue