public void StockerPlcIntegrationTest() { StockerSimulatorPlcCommunication simulator = StockerSimulatorPlcCommunication.Create(); IStockerPlc target = new StockerPlc(simulator); target.Open(); bool barcodeError = false; CarrierPlateRouting routing = CarrierPlateRouting.Cleared; bool isMagazineChanged = false; bool isMagazineBarcodeReadedOk = false; StockerInventory inventory = StockerInventory.Cleared; MagazineSelection selection = MagazineSelection.Cleared; IStockerStatus status = target.GetStatus(); CompareObjects(simulator, status); for (int i = 0; i < 100000; i++) { // "PLC" randomly clear memory if (_random.NextDouble() > 0.40) { switch (_random.Next(2, 7)) { case 2: routing = CarrierPlateRouting.Cleared; simulator.CarrierPlateRouting = routing; break; case 3: isMagazineChanged = false; simulator.IsMagazineChange = isMagazineChanged; break; case 4: isMagazineBarcodeReadedOk = false; simulator.IsInputMagazineBarcodeOK = isMagazineBarcodeReadedOk; break; case 5: inventory = StockerInventory.Cleared; simulator.StockerInventory = inventory; break; case 6: selection = MagazineSelection.Cleared; simulator.Selection = selection; break; } } // "Information system" randomly write to memory if (_random.NextDouble() > 0.50) { switch (_random.Next(1, 7)) { case 1: barcodeError = (_random.NextDouble() > 0.5) ? true : false; target.WriteBarcodeError(barcodeError); CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection); break; case 2: routing = (_random.NextDouble() > 0.5) ? CarrierPlateRouting.InsertIntoMagazine : CarrierPlateRouting.Reject; target.AcceptCarrierPlate(routing); CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection); break; case 3: target.MagazineChange(); isMagazineChanged = true; CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection); break; case 4: target.MagazineBarcodeSuccesfullyReaded(); isMagazineBarcodeReadedOk = true; CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection); break; case 5: inventory = (_random.NextDouble() > 0.5) ? StockerInventory.SizeAvailable : StockerInventory.SizeNotInStocker; target.SetWaferSizeAvailable(inventory); CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection); break; case 6: selection = (_random.NextDouble() > 0.5) ? MagazineSelection.HasRequestedSize : MagazineSelection.DoesNotHaveRequestedSize; target.AcceptMagazine(selection); CompareObjects(simulator, barcodeError, routing, isMagazineChanged, isMagazineBarcodeReadedOk, inventory, selection); break; } } ChangeStatusData(simulator); status = target.GetStatus(); CompareObjects(simulator, status); } }
public void MagazineBarcodeSuccesfullyReaded1Test() { Mock<ICommunication> plcComm = PlcHelper.GetPlcCommunicationMock(); StockerPlc target = new StockerPlc(plcComm.Object); target.Open(); target.MagazineBarcodeSuccesfullyReaded(); plcComm.Verify(x => x.Write(It.IsAny<string>()), Times.Exactly(1)); plcComm.Verify(x => x.Write(PlcHelper.GetBoolWriteCommand(true, 0x127)), Times.Exactly(1)); }