public void SendPosition_IncorrectValues_Exception(string[] arr, bool expected) { ICheck checkMoq = Mock.Of <ICheck>(check => check.CheckValuesCorrectness(arr) == expected); PositionAddCommunication p = new PositionAddCommunication(checkMoq); Action act = () => p.SendPosition(arr); act.Should().Throw <ArgumentException>(); }
public void OnSendPositiondIsCalled(string[] arr, bool expectedOut, bool expectedEvent) { ICheck checkMoq = Mock.Of <ICheck>(check => check.CheckValuesCorrectness(arr) == expectedOut); PositionAddCommunication p = new PositionAddCommunication(checkMoq); bool wasEventCalled = false; p.DataSend += (sender, args) => wasEventCalled = true; try { p.SendPosition(arr); } catch (ArgumentException) { } wasEventCalled.Should().Be(expectedEvent); }
public void OnSendPositiondIsCalled_ReceivedMessage(string[] arr, bool expectedOut, string expectedArgs) { ICheck checkMoq = Mock.Of <ICheck>(check => check.CheckValuesCorrectness(arr) == expectedOut); PositionAddCommunication p = new PositionAddCommunication(checkMoq); string receivedCommand = ""; string receivedArgs = ""; p.DataSend += (sender, args) => { receivedCommand = args.command; receivedArgs = args.args; }; try { p.SendPosition(arr); } catch (ArgumentException) { } receivedCommand.Should().Be("PD"); receivedArgs.Should().Be(expectedArgs); }