コード例 #1
0
        void TestParseInstruction <T>(byte[] byteCode, IComparable <T> expected) where T : class
        {
            Int16 instructionCode = BitConverter.ToInt16(byteCode);
            InstructionConfiguratorStub configurator = new InstructionConfiguratorStub();
            InstructionParser           parser       = new InstructionParser(configurator);
            var parsed = parser.Parse(instructionCode) as T;

            Assert.Equal(0, expected.CompareTo(parsed));
        }
コード例 #2
0
        void TestInvalidInstructionCall(byte[] byteCode)
        {
            Int16 instructionCode = BitConverter.ToInt16(byteCode);
            InstructionConfiguratorStub configurator = new InstructionConfiguratorStub();
            InstructionParser           parser       = new InstructionParser(configurator);

            parser.UnknownInstructionFoundEvent += (Int16 code) => throw new InvalidInstructionException();
            Assert.Throws <InvalidInstructionException>(() => parser.Parse(instructionCode));
        }