mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-13 07:11:56 +01:00
Added: Complex Tests for ToCheck and Transfer
This commit is contained in:
parent
8170f93d59
commit
08d0fe449c
@ -410,7 +410,6 @@ namespace FabAccessAPI_Test
|
|||||||
[Order(3)]
|
[Order(3)]
|
||||||
public class Machine_Test
|
public class Machine_Test
|
||||||
{
|
{
|
||||||
|
|
||||||
#region SetUp
|
#region SetUp
|
||||||
public async Task ForceFree(string username, string machineID)
|
public async Task ForceFree(string username, string machineID)
|
||||||
{
|
{
|
||||||
@ -485,39 +484,219 @@ namespace FabAccessAPI_Test
|
|||||||
Assert.AreEqual(MachineState.free, machine.State);
|
Assert.AreEqual(MachineState.free, machine.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("MakerQRA", "MachineA1")]
|
[TestCase("ManagerA1", "MakerA1", "MachineA1")]
|
||||||
[Order(1)]
|
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||||
public async Task UseWithoutDiscloseMaschineList(string username, string machineID)
|
[TestCase("ManagerA1", "GuestA1", "MachineA1")]
|
||||||
|
[Order(2)]
|
||||||
|
public async Task TransferMachine(string username1, string username2, string machineID)
|
||||||
{
|
{
|
||||||
Connection connection = await API_TestEnv_Test.Connect(username);
|
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||||
Session session = connection.Session;
|
Session session1 = connection1.Session;
|
||||||
|
|
||||||
MachineSystem.IInfoInterface infoInterface = await session.MachineSystem.Info().ConfigureAwait(false);
|
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||||
Machine machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
|
Session session2 = connection1.Session;
|
||||||
|
|
||||||
|
MachineSystem.IInfoInterface infoInterface1 = await session1.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
MachineSystem.IInfoInterface infoInterface2 = await session2.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
// Check State before run Test
|
// Check State before run Test
|
||||||
if (machine.State != MachineState.free)
|
if (machine1.State != MachineState.free)
|
||||||
{
|
{
|
||||||
API_TestEnv_Test.Disconnect(connection);
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
Assert.Inconclusive("State is not 'free'");
|
Assert.Inconclusive("State is not 'free'");
|
||||||
}
|
}
|
||||||
|
|
||||||
await machine.Use.Use().ConfigureAwait(false);
|
await machine1.Use.Use().ConfigureAwait(false);
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.Releasefortakeover().ConfigureAwait(false);
|
||||||
|
|
||||||
IReadOnlyList<Machine> machines = await infoInterface.GetMachineList().ConfigureAwait(false);
|
Machine machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
if(machines.Count != 1 && machines[0].Id != machineID)
|
await machine2.Takeover.Accept().ConfigureAwait(false);
|
||||||
{
|
|
||||||
Assert.Fail();
|
machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine2.Inuse.GiveBack().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
|
||||||
|
Assert.AreEqual(MachineState.free, machine1.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
|
[TestCase("ManagerA1", "MakerA1", "MachineA1")]
|
||||||
await machine.Inuse.GiveBack().ConfigureAwait(false);
|
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||||
|
[TestCase("ManagerA1", "GuestA1", "MachineA1")]
|
||||||
|
[Order(3)]
|
||||||
|
public async Task TransferMachine_Reject(string username1, string username2, string machineID)
|
||||||
|
{
|
||||||
|
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||||
|
Session session1 = connection1.Session;
|
||||||
|
|
||||||
machine = await infoInterface.GetMachine(machineID).ConfigureAwait(false);
|
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||||
|
Session session2 = connection1.Session;
|
||||||
|
|
||||||
API_TestEnv_Test.Disconnect(connection);
|
MachineSystem.IInfoInterface infoInterface1 = await session1.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
MachineSystem.IInfoInterface infoInterface2 = await session2.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
|
||||||
Assert.AreEqual(MachineState.free, machine.State);
|
Machine machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
// Check State before run Test
|
||||||
|
if (machine1.State != MachineState.free)
|
||||||
|
{
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
Assert.Inconclusive("State is not 'free'");
|
||||||
|
}
|
||||||
|
|
||||||
|
await machine1.Use.Use().ConfigureAwait(false);
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.Releasefortakeover().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine2.Takeover.Reject().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine2 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
|
||||||
|
Assert.AreEqual(MachineState.free, machine2.State);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("ManagerA1", "ManagerA1", "MachineA1")]
|
||||||
|
[TestCase("ManagerA1", "Admin1", "MachineA1")]
|
||||||
|
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||||
|
[Order(4)]
|
||||||
|
public async Task CheckMachine(string username1, string username2, string machineID)
|
||||||
|
{
|
||||||
|
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||||
|
Session session1 = connection1.Session;
|
||||||
|
|
||||||
|
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||||
|
Session session2 = connection1.Session;
|
||||||
|
|
||||||
|
MachineSystem.IInfoInterface infoInterface1 = await session1.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
MachineSystem.IInfoInterface infoInterface2 = await session2.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
// Check State before run Test
|
||||||
|
if (machine1.State != MachineState.free)
|
||||||
|
{
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
Assert.Inconclusive("State is not 'free'");
|
||||||
|
}
|
||||||
|
|
||||||
|
await machine1.Use.Use().ConfigureAwait(false);
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine2.Check.Check().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
|
||||||
|
Assert.AreEqual(MachineState.free, machine1.State);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("ManagerA1", "ManagerA1", "MachineA1")]
|
||||||
|
[TestCase("ManagerA1", "Admin1", "MachineA1")]
|
||||||
|
[TestCase("MakerA1", "Admin1", "MachineA1")]
|
||||||
|
[Order(5)]
|
||||||
|
public async Task CheckMachine_Reject(string username1, string username2, string machineID)
|
||||||
|
{
|
||||||
|
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||||
|
Session session1 = connection1.Session;
|
||||||
|
|
||||||
|
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||||
|
Session session2 = connection1.Session;
|
||||||
|
|
||||||
|
MachineSystem.IInfoInterface infoInterface1 = await session1.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
MachineSystem.IInfoInterface infoInterface2 = await session2.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
// Check State before run Test
|
||||||
|
if (machine1.State != MachineState.free)
|
||||||
|
{
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
Assert.Inconclusive("State is not 'free'");
|
||||||
|
}
|
||||||
|
|
||||||
|
await machine1.Use.Use().ConfigureAwait(false);
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine2.Check.Reject().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine2.Check.Check().ConfigureAwait(false);
|
||||||
|
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
|
||||||
|
Assert.AreEqual(MachineState.free, machine1.State);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("MakerA1", "GuestA1", "ManagerA1", "MachineA1")]
|
||||||
|
[Order(4)]
|
||||||
|
public async Task CheckMachine_NoPermission(string username1, string username2, string username3, string machineID)
|
||||||
|
{
|
||||||
|
Connection connection1 = await API_TestEnv_Test.Connect(username1);
|
||||||
|
Session session1 = connection1.Session;
|
||||||
|
|
||||||
|
Connection connection2 = await API_TestEnv_Test.Connect(username2);
|
||||||
|
Session session2 = connection1.Session;
|
||||||
|
|
||||||
|
Connection connection3 = await API_TestEnv_Test.Connect(username3);
|
||||||
|
Session session3 = connection1.Session;
|
||||||
|
|
||||||
|
MachineSystem.IInfoInterface infoInterface1 = await session1.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
MachineSystem.IInfoInterface infoInterface2 = await session2.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
MachineSystem.IInfoInterface infoInterface3 = await session3.MachineSystem.Info().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
|
||||||
|
// Check State before run Test
|
||||||
|
if (machine1.State != MachineState.free)
|
||||||
|
{
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
Assert.Inconclusive("State is not 'free'");
|
||||||
|
}
|
||||||
|
|
||||||
|
await machine1.Use.Use().ConfigureAwait(false);
|
||||||
|
machine1 = await infoInterface1.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine1.Inuse.GiveBack().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Machine machine2 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
bool result = ((CheckInterface_Proxy)machine2.Check).IsNull;
|
||||||
|
|
||||||
|
Machine machine3 = await infoInterface2.GetMachine(machineID).ConfigureAwait(false);
|
||||||
|
await machine3.Check.Check().ConfigureAwait(false);
|
||||||
|
|
||||||
|
API_TestEnv_Test.Disconnect(connection1);
|
||||||
|
API_TestEnv_Test.Disconnect(connection2);
|
||||||
|
|
||||||
|
Assert.IsTrue(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user