Ready to test Max RDS
This commit is contained in:
@ -17,12 +17,27 @@ public class AppSettings
|
||||
public string InboundApiAllowedIPList { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string Oi2SqlConnectionString { init; get; }
|
||||
public string OIExportPath { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string apiLoggingContentTypes, string apiLoggingPathPrefixes, string apiLogPath, string attachmentPath, string buildNumber, string company, string connectionString, string gitCommitSeven, string inboundApiAllowedIPList, string monAResource, string monASite, string oiExportPath, string urls, string workingDirectoryName)
|
||||
public AppSettings(string apiLoggingContentTypes,
|
||||
string apiLoggingPathPrefixes,
|
||||
string apiLogPath,
|
||||
string attachmentPath,
|
||||
string buildNumber,
|
||||
string company,
|
||||
string connectionString,
|
||||
string gitCommitSeven,
|
||||
string inboundApiAllowedIPList,
|
||||
string monAResource,
|
||||
string monASite,
|
||||
string oi2SqlConnectionString,
|
||||
string oiExportPath,
|
||||
string urls,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
ApiLoggingContentTypes = apiLoggingContentTypes;
|
||||
ApiLoggingPathPrefixes = apiLoggingPathPrefixes;
|
||||
@ -35,6 +50,7 @@ public class AppSettings
|
||||
InboundApiAllowedIPList = inboundApiAllowedIPList;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
Oi2SqlConnectionString = oi2SqlConnectionString;
|
||||
OIExportPath = oiExportPath;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
|
@ -20,6 +20,7 @@ public class AppSettings
|
||||
[Display(Name = "Inbound Api Allowed IP List"), Required] public string InboundApiAllowedIPList { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "Oi 2 Sql Connection String"), Required] public string Oi2SqlConnectionString { get; set; }
|
||||
[Display(Name = "OI Export Path"), Required] public string OIExportPath { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
@ -47,6 +48,7 @@ public class AppSettings
|
||||
appSettings.InboundApiAllowedIPList,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.Oi2SqlConnectionString,
|
||||
appSettings.OIExportPath,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
|
@ -44,10 +44,13 @@
|
||||
<ProjectReference Include="..\Archive\Archive.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="appsettings.json">
|
||||
<None Include="..\Archive\appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="appsettings.Development.json">
|
||||
<None Include="..\Archive\appsettings.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\.Data\RdsMaxRepo.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
@ -1,10 +1,15 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OI.Metrology.Archive.Repositories;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Shared.Repositories;
|
||||
using OI.Metrology.Tests.Models;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.Tests;
|
||||
namespace OI.Metrology.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class UnitTestArchive
|
||||
@ -13,6 +18,7 @@ public class UnitTestArchive
|
||||
private readonly ILogger _Logger;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly string _WorkingDirectory;
|
||||
private readonly IMemoryCache? _MemoryCache;
|
||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||
|
||||
public UnitTestArchive()
|
||||
@ -27,13 +33,17 @@ public class UnitTestArchive
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.Development.json");
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = OI.Metrology.Tests.Models.Binder.AppSettings.Get(configurationRoot);
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
logger = Log.ForContext<UnitTestArchive>();
|
||||
logger.Information("Complete");
|
||||
ServiceCollection services = new();
|
||||
ServiceProvider serviceProvider = services.BuildServiceProvider();
|
||||
_ = services.AddMemoryCache();
|
||||
_MemoryCache = serviceProvider.GetService<IMemoryCache>();
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_WorkingDirectory = workingDirectory;
|
||||
@ -56,7 +66,23 @@ public class UnitTestArchive
|
||||
Assert.IsFalse(_AppSettings is null);
|
||||
Assert.IsFalse(_WorkingDirectory is null);
|
||||
Assert.IsFalse(_ConfigurationRoot is null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodArchiveJson()
|
||||
{
|
||||
string json;
|
||||
string jsonFile = Path.Combine(AppContext.BaseDirectory, "RdsMaxRepo.json");
|
||||
Assert.IsTrue(File.Exists(jsonFile));
|
||||
json = JsonSerializer.Serialize(_AppSettings);
|
||||
IDbConnectionFactory dbConnectionFactory = new SQLDbConnectionFactory(json);
|
||||
IRdsMaxRepo rdsMaxRepo = new RdsMaxRepo(dbConnectionFactory, _MemoryCache);
|
||||
json = File.ReadAllText(jsonFile);
|
||||
Shared.DataModels.RDS.Max[]? collection = JsonSerializer.Deserialize<Shared.DataModels.RDS.Max[]>(json);
|
||||
if (collection is null)
|
||||
throw new NullReferenceException(nameof(collection));
|
||||
List<string[]> data = rdsMaxRepo.Convert(collection);
|
||||
Assert.IsTrue(data.Any());
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,7 @@ using OI.Metrology.Tests.Models;
|
||||
using Serilog;
|
||||
using System.Reflection;
|
||||
|
||||
namespace View_by_Distance.Tests;
|
||||
namespace OI.Metrology.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class UnitTestExample
|
||||
|
@ -1,61 +0,0 @@
|
||||
{
|
||||
"AllowedHosts": "*",
|
||||
"ApiLoggingContentTypes": "application/json",
|
||||
"ApiLoggingPathPrefixes": "/api/inbound",
|
||||
"ApiLogPath": "D:\\Metrology\\MetrologyAPILogs",
|
||||
"AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments",
|
||||
"BuildNumber": "1",
|
||||
"Company": "Infineon Technologies Americas Corp.",
|
||||
"ConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology_Archive;",
|
||||
"GitCommitSeven": "1234567",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonASite": "auc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Debug",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "%workingDirectory% - Log/log-.txt",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [
|
||||
"FromLogContext",
|
||||
"WithMachineName",
|
||||
"WithThreadId"
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"URLs": "https://localhost:7130;http://localhost:5126",
|
||||
"WorkingDirectoryName": "IFXApps"
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
{
|
||||
"AllowedHosts": "*",
|
||||
"ApiLoggingContentTypes": "application/json",
|
||||
"ApiLoggingPathPrefixes": "/api/inbound",
|
||||
"ApiLogPath": "D:\\Metrology\\MetrologyAPILogs",
|
||||
"AttachmentPath": "\\\\messv02ecc1.ec.local\\EC_Metrology_Si\\MetrologyAttachments",
|
||||
"BuildNumber": "1",
|
||||
"Company": "Infineon Technologies Americas Corp.",
|
||||
"ConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology_Archive;",
|
||||
"GitCommitSeven": "1234567",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Log4netProvider": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"InboundApiAllowedIPList": "",
|
||||
"MonASite": "auc",
|
||||
"OIExportPath": "\\\\openinsight-db-srv.na.infineon.com\\apps\\Metrology\\Data",
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Debug",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "%workingDirectory% - Log/log-.txt",
|
||||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] ({SourceContext}.{MethodName}) ({InstanceId}) ({RemoteIpAddress}) {Message}{NewLine}{Exception}",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [
|
||||
"FromLogContext",
|
||||
"WithMachineName",
|
||||
"WithThreadId"
|
||||
],
|
||||
"Properties": {
|
||||
"Application": "Sample"
|
||||
}
|
||||
},
|
||||
"URLs": "http://localhost:5002;",
|
||||
"WorkingDirectoryName": "IFXApps"
|
||||
}
|
Reference in New Issue
Block a user