Added more Tests for Machine

This commit is contained in:
TheJoKlLa 2022-04-21 01:20:30 +02:00
parent 3561bb2771
commit 90fbd0ff1b
2 changed files with 133 additions and 128 deletions

View File

@ -58,6 +58,7 @@ namespace FabAccessAPI_Test
}
[TestFixture, Parallelizable(ParallelScope.Children)]
[Order(1)]
public class MachineSystem_Test
{
[TestCase("Admin1", true)]
@ -259,13 +260,35 @@ namespace FabAccessAPI_Test
}
[TestFixture, Parallelizable(ParallelScope.Children)]
public class Machine_Test
[Order(2)]
public class Machine_Test_Stateless
{
[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")]
[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", true)]
[TestCase("GuestB1", "MachineB1", true)]
[TestCase("GuestC1", "MachineC1", true)]
[TestCase("MakerQRA", "MachineA1", true)]
[TestCase("MakerQRB", "MachineB1", true)]
[TestCase("MakerQRC", "MachineC1", true)]
[Order(1)]
public async Task ReadMachineData(string username, string machineID, string description, string wiki, string category)
public async Task InfoInterface(string username, string machineID, bool expectInterface)
{
Connection connection = await API_TestEnv_Test.Connect(username);
Session session = connection.Session;
@ -273,132 +296,13 @@ namespace FabAccessAPI_Test
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;
bool result = !((Machine.InfoInterface_Proxy)machine.Info).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)]
@ -423,7 +327,7 @@ namespace FabAccessAPI_Test
[TestCase("MakerQRA", "MachineA1", false)]
[TestCase("MakerQRB", "MachineB1", false)]
[TestCase("MakerQRC", "MachineC1", false)]
[Order(5)]
[Order(2)]
public async Task ManageInterface(string username, string machineID, bool expectInterface)
{
Connection connection = await API_TestEnv_Test.Connect(username);
@ -463,7 +367,7 @@ namespace FabAccessAPI_Test
//[TestCase("MakerQRA", "MachineA1", false)]
//[TestCase("MakerQRB", "MachineB1", false)]
//[TestCase("MakerQRC", "MachineC1", false)]
//[Order(6)]
//[Order(3)]
//public async Task AdminInterface(string username, string machineID, bool expectInterface)
//{
// Connection connection = await API_TestEnv_Test.Connect(username);
@ -478,5 +382,106 @@ namespace FabAccessAPI_Test
// Assert.AreEqual(expectInterface, result);
//}
[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(4)]
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);
});
}
}
[TestFixture]
[Order(3)]
public class Machine_Test
{
public async Task ForceFree(string username, string machineID)
{
Console.WriteLine("start: " + machineID);
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);
await machine.Manage.ForceFree().ConfigureAwait(false);
API_TestEnv_Test.Disconnect(connection);
Console.WriteLine("finished: " + machineID);
}
[OneTimeSetUp]
public async Task OneTimeSetUp()
{
List<Task> tasks = new List<Task>()
{
ForceFree("Admin1", "MachineA1"),
ForceFree("Admin1", "MachineA2"),
ForceFree("Admin1", "MachineA3"),
ForceFree("Admin1", "MachineA4"),
ForceFree("Admin1", "MachineA5"),
ForceFree("Admin1", "MachineB1"),
ForceFree("Admin1", "MachineB2"),
ForceFree("Admin1", "MachineB3"),
ForceFree("Admin1", "MachineB4"),
ForceFree("Admin1", "MachineB5"),
ForceFree("Admin1", "MachineC1"),
ForceFree("Admin1", "MachineC2"),
ForceFree("Admin1", "MachineC3"),
ForceFree("Admin1", "MachineC4"),
ForceFree("Admin1", "MachineC5")
};
await Task.WhenAll(tasks);
}
// TODO: Force State before Test
[TestCase("Admin1", "MachineA1")]
[TestCase("ManagerA1", "MachineA1")]
[TestCase("MakerA1", "MachineA1")]
[Order(1)]
public async Task UseGiveBack(string username, string machineID)
{
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);
// Check State before run Test
if(machine.State != MachineState.free)
{
API_TestEnv_Test.Disconnect(connection);
Assert.Inconclusive("State is not 'free'");
}
await machine.Use.Use().ConfigureAwait(false);
machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
await machine.Inuse.GiveBack().ConfigureAwait(false);
machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
API_TestEnv_Test.Disconnect(connection);
Assert.AreEqual(MachineState.free, machine.State);
}
}
}

View File

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace FabAccessAPI_Test
{
[TestFixture, Order(0)]
public class Connection_Test
{
const string TESTSERVER = "bffh.lab.bln.kjknet.de";