PlanTempusApp/Tests/PostgresTests.cs

78 lines
No EOL
2.5 KiB
C#

using Autofac;
using System.Data;
using Insight.Database;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Logging;
using Core.Telemetry;
namespace Tests
{
[TestClass]
public class PostgresTests : TestFixture
{
[TestMethod]
public void TestDefaultConnection()
{
var conn = Container.Resolve<IDbConnection>();
//https://www.reddit.com/r/dotnet/comments/6wdoyn/how_to_properly_register_dapper_on_net_core_2_di/
//https://www.code4it.dev/blog/postgres-crud-dapper/
//https://stackoverflow.com/questions/69169247/how-to-create-idbconnection-factory-using-autofac-for-dapper
conn.ExecuteSql("SELECT 1 as p");
}
static HttpClient _client = new HttpClient();
[TestMethod]
public async Task MyTestMethod()
{
_client.BaseAddress = new Uri("http://localhost:5341");
var l = new SeqLogger(_client, "", "");
for (int i = 0; i < 20; i++)
{
await l.LogToSeq(
"Bruger {UserId} loggede ind",
"Debug",
new Dictionary<string, object> { { "UserId", "12345" }, { "Counter", i++ } }
);
}
var logger = Container.Resolve<Microsoft.ApplicationInsights.TelemetryClient>();
for (int i = 0; i < 5; i++)
{
logger.TrackTrace("Hello 23" , Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Information);
}
}
[TestMethod]
public void TryOrganizationSetupService()
{
var conn = Container.Resolve<IDbConnection>();
}
[TestMethod]
public async Task TryDbSetup()
{
//var conn = Container.Resolve<IDbConnection>();
//var identitySystem = new Database.Core.SetupIdentitySystem(conn);
//identitySystem.CreateSystem("swp");
}
[TestMethod]
public void SetupPostgresql_LISTEN()
{
//var builder = new ConfigurationBuilder()
// .AddPostgresConfiguration(options =>
// {
// options.ConnectionString = "Host=192.168.1.57;Database=ptdb01;Username=postgres;Password=3911";
// options.Channel = "config_changes";
// options.ConfigurationQuery = @"select * from dev.app_configuration";
// });
}
}
}