複数の OPC UA セッション ( UnifiedAutomation.UaClient.Session )で動作するサービスを含む C# アプリケーションがあります。これらのセッションは、opc.tcp://localhost:48030 などのアドレスに接続することによって作成されます。
foreach (ConnectionStringSettings connectionSettings in ConfigurationManager.ConnectionStrings)
{
var connectionString = connectionSettings.ConnectionString;
// Ignore non-OPC-connections
if (!connectionString.StartsWith("opc.tcp")) continue;
// Create new session for connection
var session = new Session
{
AutomaticReconnect = true,
ReconnectDelay = 0
};
// Connect to OPC UA Server
try
{
session.Connect(connectionString, SecuritySelection.None);
Log("OPC UA Session establish.", EventLogEntryType.Information);
}
catch (StatusException)
{
Log($"No OPC UA Server found at {connectionString}.",
EventLogEntryType.Warning);
}
}
サービスのメソッドを単体テストしたいのですが、OPC UA セッションをモックする方法がわかりません。
これがまったく可能かどうか、考えはありますか?