public DecryptedDevice(ICryptoHandler cryptographyHandler, IDevice device) { if (cryptographyHandler == null) { throw new ArgumentNullException(nameof(cryptographyHandler)); } if (device == null) { throw new ArgumentNullException(nameof(device)); } this.CryptographyHandler = cryptographyHandler; this.inputLink = new DataLink(); this.inputLink.CommandReceived += this.OnInputLinkCommandReceived; this.inputLink.CorruptCommandReceived += this.OnInputLinkCorruptCommandReceived; this.inputLink.AbortRequested += this.OnInputLinkAbortRequested; this.outputLink = new DataLink(); this.outputLink.CommandReceived += this.OnOutputLinkCommandReceived; this.outputLink.CorruptCommandReceived += this.OnOutputLinkCorruptCommandReceived; this.outputLink.AbortRequested += this.OnOutputLinkAbortRequested; this.device = device; this.device.Output += this.OnDeviceOutput; }
public RegexSimulatedDevice(ICryptoHandler cryptographyHandler, Dictionary <Regex, string> regexPatternDictionary) : base(cryptographyHandler) { if (regexPatternDictionary == null) { throw new ArgumentNullException(nameof(regexPatternDictionary)); } this.regexResponsePatternDictionary = regexPatternDictionary; this.CommandReceived += this.OnCommandReceived; }
public void Initialize() { this.device = Substitute.For <IDevice>(); this.cryptoHandler = Substitute.For <ICryptoHandler>(); this.emulator = new Emulator(this.device, this.cryptoHandler); this.cryptoHandler.Undo(Arg.Any <string>()).Returns((callInfo) => callInfo.Arg <string>()); this.device.When(d => d.Input(Arg.Any <byte[]>())).Do(data => { this.device.Output += Raise.Event <Action <byte[]> >(data.Arg <byte[]>()); }); }
public VirtualDevice(ICryptoHandler cryptographyHandler) { if (cryptographyHandler == null) { throw new ArgumentNullException(nameof(cryptographyHandler)); } this.CryptographyHandler = cryptographyHandler; this.link = new DataLink(); this.link.CommandReceived += this.OnLinkCommandReceived; this.link.CorruptCommandReceived += this.OnLinkCorruptCommandReceived; this.link.AbortRequested += this.OnLinkAbortRequested; }
public Emulator(IDevice device, ICryptoHandler cryptoHandler) { this.device = device ?? throw new ArgumentNullException(nameof(device)); this.cryptoHandler = cryptoHandler ?? throw new ArgumentNullException(nameof(cryptoHandler)); this.device = device; this.device.Output += this.OnDeviceOutput; this.dataLink = new DataLink(); this.deserializer = new Deserializer(); this.dataLink.CommandReceived += this.OnCommandReceived; this.dataLink.CorruptCommandReceived += this.OnCorruptCommandReceived; this.dataLink.AbortRequested += this.OnAbortRequested; }