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)); }
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)); }