mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 23:01:52 +01:00
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
using FabAccessAPI;
|
|
using Capnp;
|
|
using Capnp.Rpc;
|
|
using log4net.Config;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace FabAccessAPI_Test {
|
|
public class Tests {
|
|
#region Log
|
|
private static readonly log4net.ILog _Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
#endregion
|
|
|
|
private static ILoggerFactory _loggerFactory;
|
|
private Connection _connection;
|
|
|
|
[OneTimeSetUp]
|
|
public void InitialSetup() {
|
|
XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
|
|
_loggerFactory = LoggerFactory.Create(builder => {
|
|
builder
|
|
.AddFilter("Microsoft", LogLevel.Warning)
|
|
.AddFilter("System", LogLevel.Warning);
|
|
});
|
|
_loggerFactory.AddLog4Net();
|
|
Logging.LoggerFactory = _loggerFactory;
|
|
}
|
|
|
|
[SetUp]
|
|
public void Setup() {
|
|
TcpRpcClient rpcClient = new TcpRpcClient();
|
|
rpcClient.Connect("[::1]", 59661);
|
|
_connection = new Connection(rpcClient);
|
|
}
|
|
|
|
[TearDown]
|
|
public void Teardown() {
|
|
_connection.RpcClient?.Dispose();
|
|
_connection = null;
|
|
}
|
|
|
|
[Test]
|
|
public void Connect() {
|
|
Assert.AreEqual(ConnectionState.Active, _connection.RpcClient.State);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Authenticate() {
|
|
await _connection.Auth("PLAIN", new Dictionary<string, object>{{"Username", "Testuser"}, {"Password", "secret"}});
|
|
}
|
|
}
|
|
} |