This commit is contained in:
Janus C. H. Knudsen 2025-03-10 15:56:22 +01:00
parent f3ab94eff1
commit 31666b4ba0
34 changed files with 140 additions and 83 deletions

View file

@ -2,7 +2,7 @@
using Autofac;
using Insight.Database;
using Newtonsoft.Json;
using PlanTempus.Core.Sql.ConnectionFactory;
using PlanTempus.Core.Database.ConnectionFactory;
using Shouldly;
namespace PlanTempus.X.TDD.ConfigurationSystem;

View file

@ -3,7 +3,7 @@ using Insight.Database;
using PlanTempus.Core.Configurations;
using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.Configurations.SmartConfigProvider;
using PlanTempus.Core.Sql.ConnectionFactory;
using PlanTempus.Core.Database.ConnectionFactory;
using Shouldly;
namespace PlanTempus.X.TDD.ConfigurationTests;

View file

@ -3,7 +3,7 @@ using Autofac;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using PlanTempus.Core.Logging;
using PlanTempus.Core.SeqLogging;
using PlanTempus.Core.Telemetry;
namespace PlanTempus.X.TDD.Logging;

View file

@ -1,7 +1,7 @@
using Autofac;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using PlanTempus.Core.Logging;
using PlanTempus.Core.SeqLogging;
namespace PlanTempus.X.TDD.Logging;

View file

@ -2,7 +2,7 @@ using Autofac;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using PlanTempus.Core.Logging;
using PlanTempus.Core.SeqLogging;
using PlanTempus.Core.Telemetry;
namespace PlanTempus.X.TDD.Logging;

View file

@ -20,6 +20,7 @@
<ItemGroup>
<ProjectReference Include="..\Application\PlanTempus.Application.csproj"/>
<ProjectReference Include="..\Database\PlanTempus.Database.csproj"/>
<ProjectReference Include="..\PlanTempus.Components\PlanTempus.Components.csproj" />
</ItemGroup>
<ItemGroup>

View file

@ -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()
{

View file

@ -4,8 +4,8 @@ using Microsoft.ApplicationInsights;
using Microsoft.Extensions.Logging;
using PlanTempus.Core.Configurations;
using PlanTempus.Core.Configurations.JsonConfigProvider;
using PlanTempus.Core.Logging;
using PlanTempus.Core.ModuleRegistry;
using PlanTempus.Core.SeqLogging;
using PlanTempus.Database.ModuleRegistry;
namespace PlanTempus.X.TDD;