public void GivenNoChecksum_Validate_ReturnsFalse() { var message = new TestFixMessageBuilder(TestFixMessageBuilder.DefaultBody).AddChecksum("3").Build(); var uut = new ChecksumValidator(IntegerToFixConverter.Instance); var msgContext = new FixMessageContext().Setup(message); var result = uut.IsValid(message.AsSpan(), msgContext); Assert.False(result); }
public void GivenCorrectChecksum_Validate_ReturnsTrue(string input) { byte[] message = new TestFixMessageBuilder(input).Build(out byte checksumValue, out int checksumStart); var uut = new ChecksumValidator(IntegerToFixConverter.Instance); var msgContext = new FixMessageContext() { ChecksumValue = checksumValue, ChecksumTagStartIndex = checksumStart }; var result = uut.IsValid(message.AsSpan(), msgContext); Assert.True(result); }
public void GameUpdate(float dt, int frame) { bool isChecksumFrame = IsChecksumFrame(frame); if (_recording) { _replayRecorder.Record(_gameFixedUpdate.CurrentGameFrame, isChecksumFrame); } else { _replayPlayer.Replay(_gameFixedUpdate.CurrentGameFrame); if (isChecksumFrame) { bool validState = _checksumValidator.IsValid(frame, _checksumProvider.CalculateChecksum(), _replay.StoredChecksums); } } }
public void GameUpdate(float dt, int frame) { if (_commandSender.IsReady()) { _commandSender.SendCommands(); } if (!_replayController.IsRecording) { var isValid = _checkumValidator.IsValid(frame, _checksumProvider.CalculateChecksum(), _replayController.Replay.StoredChecksums); if (isValid) { Debug.LogFormat("State for frame {0} is: {1}", frame, "VALID"); } else { Debug.LogWarningFormat("State for frame {0} is: {1}", frame, "INVALID"); var myCustomReplay = _replayController.Replay as MyCustomReplay; var storedGameState = myCustomReplay.GetStoredGameState(frame) as MyCustomGameState; var currentGameState = GetGameState() as MyCustomGameState; Debug.LogWarningFormat("Stored gamestate: {0}", storedGameState.GetStateString()); Debug.LogWarningFormat("Current gamestate: {0}", currentGameState.GetStateString()); } // var storedChecksums = _replayController.Replay.StoredChecksums; } _replayController.GameUpdate(dt, frame); unit.Unit.GameUpdate(dt, frame); }