예제 #1
0
        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;
        }
예제 #2
0
        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;
        }
예제 #3
0
        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[]>());
            });
        }
예제 #4
0
        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;
        }
예제 #5
0
        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;
        }