Added Access Tests for Machine Interfaces

This commit is contained in:
TheJoKlLa 2022-04-20 23:20:24 +02:00
parent 6194d1bb9e
commit 3561bb2771

View File

@ -8,6 +8,7 @@ using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using static FabAccessAPI.Schema.Machine;
using static FabAccessAPI.Schema.MachineSystem;
namespace FabAccessAPI_Test
@ -57,7 +58,7 @@ namespace FabAccessAPI_Test
}
[TestFixture, Parallelizable(ParallelScope.Children)]
public class MachineSystem
public class MachineSystem_Test
{
[TestCase("Admin1", true)]
[TestCase("Admin2", true)]
@ -133,7 +134,7 @@ namespace FabAccessAPI_Test
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
IReadOnlyList<Machine> machine_list = await infoInterface.GetMachineList().ConfigureAwait(false);
int result = machine_list.Count;
@ -174,7 +175,7 @@ namespace FabAccessAPI_Test
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(machineName).ConfigureAwait(false);
bool result = machine != null;
@ -191,7 +192,7 @@ namespace FabAccessAPI_Test
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(machineName).ConfigureAwait(false);
API_TestEnv_Test.Disconnect(connection);
@ -230,7 +231,7 @@ namespace FabAccessAPI_Test
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(urn).ConfigureAwait(false);
bool result = machine != null;
@ -248,7 +249,7 @@ namespace FabAccessAPI_Test
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(urn).ConfigureAwait(false);
API_TestEnv_Test.Disconnect(connection);
@ -256,4 +257,226 @@ namespace FabAccessAPI_Test
Assert.IsNull(machine);
}
}
}
[TestFixture, Parallelizable(ParallelScope.Children)]
public class Machine_Test
{
[TestCase("Admin1", "MachineA1", "Description of MachineA1", @"https://fab-access.readthedocs.io", "CategoryA")]
[TestCase("Admin1", "MachineB2", "Description of MachineB2", @"https://fab-access.readthedocs.io", "CategoryB")]
[TestCase("Admin1", "MachineC3", "Description of MachineC3", @"https://fab-access.readthedocs.io", "CategoryC")]
[Order(1)]
public async Task ReadMachineData(string username, string machineID, string description, string wiki, string category)
{
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
API_TestEnv_Test.Disconnect(connection);
Assert.Multiple(() =>
{
Assert.AreEqual(machineID, machine.Id);
Assert.AreEqual(description, machine.Description);
Assert.AreEqual(wiki, machine.Wiki);
Assert.AreEqual(category, machine.Category);
});
}
[TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", true)]
[TestCase("ManagerA1", "MachineB1", false)]
[TestCase("ManagerA1", "MachineC1", false)]
[TestCase("ManagerB1", "MachineA1", false)]
[TestCase("ManagerB1", "MachineB1", true)]
[TestCase("ManagerB1", "MachineC1", false)]
[TestCase("ManagerC1", "MachineA1", false)]
[TestCase("ManagerC1", "MachineB1", false)]
[TestCase("ManagerC1", "MachineC1", true)]
[TestCase("ManagerABC1", "MachineA1", true)]
[TestCase("ManagerABC1", "MachineB1", true)]
[TestCase("ManagerABC1", "MachineC1", true)]
[TestCase("MakerA1", "MachineA1", true)]
[TestCase("MakerB1", "MachineB1", true)]
[TestCase("MakerC1", "MachineC1", true)]
[TestCase("GuestA1", "MachineA1", false)]
[TestCase("GuestB1", "MachineB1", false)]
[TestCase("GuestC1", "MachineC1", false)]
[TestCase("MakerQRA", "MachineA1", true)]
[TestCase("MakerQRB", "MachineB1", true)]
[TestCase("MakerQRC", "MachineC1", true)]
[Order(2)]
public async Task UseInterface(string username, string machineID, bool expectInterface)
{
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
bool result = !((UseInterface_Proxy)machine.Use).IsNull;
API_TestEnv_Test.Disconnect(connection);
Assert.AreEqual(expectInterface, result);
}
[TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", true)]
[TestCase("ManagerA1", "MachineB1", false)]
[TestCase("ManagerA1", "MachineC1", false)]
[TestCase("ManagerB1", "MachineA1", false)]
[TestCase("ManagerB1", "MachineB1", true)]
[TestCase("ManagerB1", "MachineC1", false)]
[TestCase("ManagerC1", "MachineA1", false)]
[TestCase("ManagerC1", "MachineB1", false)]
[TestCase("ManagerC1", "MachineC1", true)]
[TestCase("ManagerABC1", "MachineA1", true)]
[TestCase("ManagerABC1", "MachineB1", true)]
[TestCase("ManagerABC1", "MachineC1", true)]
[TestCase("MakerA1", "MachineA1", true)]
[TestCase("MakerB1", "MachineB1", true)]
[TestCase("MakerC1", "MachineC1", true)]
[TestCase("GuestA1", "MachineA1", false)]
[TestCase("GuestB1", "MachineB1", false)]
[TestCase("GuestC1", "MachineC1", false)]
[TestCase("MakerQRA", "MachineA1", true)]
[TestCase("MakerQRB", "MachineB1", true)]
[TestCase("MakerQRC", "MachineC1", true)]
[Order(2)]
public async Task InUseInterface(string username, string machineID, bool expectInterface)
{
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
bool result = !((InUseInterface_Proxy)machine.Inuse).IsNull;
API_TestEnv_Test.Disconnect(connection);
Assert.AreEqual(expectInterface, result);
}
//[TestCase("MakerQRC", "MachineC1", true)]
//[Order(3)]
//public async Task TakeoverInterface(string username, string machineID, bool expectInterface)
//{
// Connection connection = await API_TestEnv_Test.Connect(username);
// Session session = connection.Session;
// MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
// Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
// bool result = !((TakeoverInterface_Proxy)machine.Takeover).IsNull;
// API_TestEnv_Test.Disconnect(connection);
// Assert.AreEqual(expectInterface, result);
//}
//[TestCase("MakerQRC", "MachineC1", true)]
//[Order(4)]
//public async Task ToCheckInterface(string username, string machineID, bool expectInterface)
//{
// Connection connection = await API_TestEnv_Test.Connect(username);
// Session session = connection.Session;
// MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
// Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
// bool result = !((CheckInterface_Proxy)machine.Check).IsNull;
// API_TestEnv_Test.Disconnect(connection);
// Assert.AreEqual(expectInterface, result);
//}
[TestCase("Admin1", "MachineA1", true)]
[TestCase("Admin1", "MachineB1", true)]
[TestCase("Admin1", "MachineC1", true)]
[TestCase("ManagerA1", "MachineA1", true)]
[TestCase("ManagerA1", "MachineB1", false)]
[TestCase("ManagerA1", "MachineC1", false)]
[TestCase("ManagerB1", "MachineA1", false)]
[TestCase("ManagerB1", "MachineB1", true)]
[TestCase("ManagerB1", "MachineC1", false)]
[TestCase("ManagerC1", "MachineA1", false)]
[TestCase("ManagerC1", "MachineB1", false)]
[TestCase("ManagerC1", "MachineC1", true)]
[TestCase("ManagerABC1", "MachineA1", true)]
[TestCase("ManagerABC1", "MachineB1", true)]
[TestCase("ManagerABC1", "MachineC1", true)]
[TestCase("MakerA1", "MachineA1", false)]
[TestCase("MakerB1", "MachineB1", false)]
[TestCase("MakerC1", "MachineC1", false)]
[TestCase("GuestA1", "MachineA1", false)]
[TestCase("GuestB1", "MachineB1", false)]
[TestCase("GuestC1", "MachineC1", false)]
[TestCase("MakerQRA", "MachineA1", false)]
[TestCase("MakerQRB", "MachineB1", false)]
[TestCase("MakerQRC", "MachineC1", false)]
[Order(5)]
public async Task ManageInterface(string username, string machineID, bool expectInterface)
{
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
bool result = !((ManageInterface_Proxy)machine.Manage).IsNull;
API_TestEnv_Test.Disconnect(connection);
Assert.AreEqual(expectInterface, result);
}
//[TestCase("Admin1", "MachineA1", true)]
//[TestCase("Admin1", "MachineB1", true)]
//[TestCase("Admin1", "MachineC1", true)]
//[TestCase("ManagerA1", "MachineA1", false)]
//[TestCase("ManagerA1", "MachineB1", false)]
//[TestCase("ManagerA1", "MachineC1", false)]
//[TestCase("ManagerB1", "MachineA1", false)]
//[TestCase("ManagerB1", "MachineB1", false)]
//[TestCase("ManagerB1", "MachineC1", false)]
//[TestCase("ManagerC1", "MachineA1", false)]
//[TestCase("ManagerC1", "MachineB1", false)]
//[TestCase("ManagerC1", "MachineC1", false)]
//[TestCase("ManagerABC1", "MachineA1", false)]
//[TestCase("ManagerABC1", "MachineB1", false)]
//[TestCase("ManagerABC1", "MachineC1", false)]
//[TestCase("MakerA1", "MachineA1", false)]
//[TestCase("MakerB1", "MachineB1", false)]
//[TestCase("MakerC1", "MachineC1", false)]
//[TestCase("GuestA1", "MachineA1", false)]
//[TestCase("GuestB1", "MachineB1", false)]
//[TestCase("GuestC1", "MachineC1", false)]
//[TestCase("MakerQRA", "MachineA1", false)]
//[TestCase("MakerQRB", "MachineB1", false)]
//[TestCase("MakerQRC", "MachineC1", false)]
//[Order(6)]
//public async Task AdminInterface(string username, string machineID, bool expectInterface)
//{
// Connection connection = await API_TestEnv_Test.Connect(username);
// Session session = connection.Session;
// MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
// Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
// bool result = !((AdminInterface_Proxy)machine.Admin).IsNull;
// API_TestEnv_Test.Disconnect(connection);
// Assert.AreEqual(expectInterface, result);
//}
}
}