public void MakeToggleOperation_NoConnectorIsConnectedAndAnyConnectorIsConnectable_SchedulesDockingOperations(params MyShipConnectorStatus[] connectorStatuses) { var testContext = new TestContext(); foreach (var connectorStatus in connectorStatuses) { testContext.AddMockConnector(connectorStatus); } testContext.Uut.MakeToggleOperation() .ShouldRunToCompletionIn(testContext.MockBackgroundWorker, 7); testContext.MockLogger .ShouldHaveReceived(x => x.AddLine(It.Is <string>(y => y.ToLower().Contains("complete")))); testContext.MockBatteryBlockManager .ShouldHaveReceived(x => x.MakeOnDockingOperation(), 1); testContext.MockBatteryBlockManager .ShouldNotHaveReceived(x => x.MakeOnUndockingOperation()); testContext.MockConnectorManager .ShouldHaveReceived(x => x.MakeOnDockingOperation(), 1); testContext.MockConnectorManager .ShouldNotHaveReceived(x => x.MakeOnUndockingOperation()); testContext.MockFunctionalBlockManager .ShouldHaveReceived(x => x.MakeOnDockingOperation(), 1); testContext.MockFunctionalBlockManager .ShouldNotHaveReceived(x => x.MakeOnUndockingOperation()); testContext.MockGasTankManager .ShouldHaveReceived(x => x.MakeOnDockingOperation(), 1); testContext.MockGasTankManager .ShouldNotHaveReceived(x => x.MakeOnUndockingOperation()); testContext.MockLandingGearManager .ShouldHaveReceived(x => x.MakeOnDockingOperation(), 1); testContext.MockLandingGearManager .ShouldNotHaveReceived(x => x.MakeOnUndockingOperation()); testContext.MockBackgroundWorker .MockSubOperationScheduler .ShouldHaveReceived(x => x(It.IsAny <IBackgroundOperation>()), 5); testContext.MockBackgroundWorker .MockSubOperationScheduler .Invocations .Where(x => x.Method.Name == nameof(Action.Invoke)) .Select(x => x.Arguments[0]) .ShouldBe(Enumerable.Empty <object>() .Append(testContext.MockConnectorsOnDockingOperation.Object) .Append(testContext.MockLandingGearsOnDockingOperation.Object) .Append(testContext.MockBatteryBlocksOnDockingOperation.Object) .Append(testContext.MockGasTanksOnDockingOperation.Object) .Append(testContext.MockFunctionalBlocksOnUndockingOperation.Object)); }
public void MakeToggleOperation_Otherwise_LogsError(params MyShipConnectorStatus[] connectorStatuses) { var testContext = new TestContext(); foreach (var connectorStatus in connectorStatuses) { testContext.AddMockConnector(connectorStatus); } testContext.Uut.MakeToggleOperation() .ShouldRunToCompletionIn(testContext.MockBackgroundWorker, 1); testContext.MockLogger .ShouldHaveReceived(x => x.AddLine(It.Is <string>(y => y.ToLower().Contains("failed") && y.ToLower().Contains("docked") && y.ToLower().Contains("dockable")))); testContext.MockBackgroundWorker .MockSubOperationScheduler .ShouldNotHaveReceived(x => x(It.IsAny <IBackgroundOperation>())); testContext.MockBatteryBlockManager .Invocations.ShouldBeEmpty(); testContext.MockConnectorManager .ShouldNotHaveReceived(x => x.MakeOnDockingOperation()); testContext.MockConnectorManager .ShouldNotHaveReceived(x => x.MakeOnUndockingOperation()); testContext.MockFunctionalBlockManager .Invocations.ShouldBeEmpty(); testContext.MockGasTankManager .Invocations.ShouldBeEmpty(); testContext.MockLandingGearManager .Invocations.ShouldBeEmpty(); }