Exemplo n.º 1
0
        public void Encode_EncodesInstructionsCorrectly(InstructionType op, Int32? operand, UInt64 expected)
        {
            // Arrange
            var encoder = new Encoder();
            var instruction = new Instruction
            {
                Type = op,
                Operand = operand.HasValue ? operand.Value : 0
            };

            // Act
            var encodedInstruction = encoder.Encode(instruction);

            // Assert
            encodedInstruction.Should().Be(expected);
        }
Exemplo n.º 2
0
        public void Encode_DoesIgnoresOperandForNonOperandInstructions(InstructionType op, Int32 operand, UInt64 expected)
        {
            // Arrange
            var encoder = new Encoder();
            var instruction = new Instruction
            {
                Type = op,
                Operand = operand
            };

            // Act
            var encodedInstruction = encoder.Encode(instruction);

            // Assert
            encodedInstruction.Should().Be(expected);
        }
Exemplo n.º 3
0
        public void Encode_NullInstructionThrowsException()
        {
            // Arrange
            var encoder = new Encoder();
            Exception exception = null;

            // Act
            try
            {
                encoder.Encode(null);
            }
            catch(Exception e)
            {
                exception = e;
            }

            // Assert
            exception.Should().NotBeNull();
            exception.Should().BeOfType<ArgumentNullException>();
            exception.As<ArgumentNullException>().ParamName.Should().Be("instruction");
        }