mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-13 07:11:56 +01:00
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
|
using System;
|
||
|
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 {
|
||
|
private static ILoggerFactory _loggerFactory;
|
||
|
[OneTimeSetUp]
|
||
|
public void Setup() {
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Connect() {
|
||
|
var rpcClient = new TcpRpcClient();
|
||
|
rpcClient.Connect("::1", 59661);
|
||
|
var con = new Connection(rpcClient);
|
||
|
Assert.AreEqual(ConnectionState.Active, rpcClient.State);
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public async Task Machines() {
|
||
|
var rpcClient = new TcpRpcClient();
|
||
|
rpcClient.Connect("::1", 59661);
|
||
|
var con = new Connection(rpcClient);
|
||
|
|
||
|
var machines = await con.AccessMachines();
|
||
|
|
||
|
var testmachine = await machines.GetMachine("Testmachine");
|
||
|
Assert.NotNull(testmachine);
|
||
|
var minfo = await testmachine.GetMInfo();
|
||
|
Assert.NotNull(minfo);
|
||
|
Console.WriteLine($"Name: {minfo.Name}, Description: {minfo.Description}, State: {minfo.State.ToString()}");
|
||
|
}
|
||
|
}
|
||
|
}
|