public void Program_should_accepT_argument_for_positions() { var validator = new IntCodeValidator(); var input = "1,9,10,3,2,3,11,0,1,2,3,3,99,30,40,50"; var adder = new AdderProgram(validator); var multiplier = new MultiplierProgram(validator); Assert.DoesNotThrow(() => multiplier.Process(input, 4)); Assert.That(multiplier.Process(input, 4), Is.EqualTo("9,9,10,3,2,3,11,0,1,2,3,3,99,30,40,50")); Assert.DoesNotThrow(() => adder.Process(input, 8)); }
public void Should_accept_start_position_when_running_progrma_mode() { var testProgram = new MultiplierProgram(new IntCodeValidator()); var program = "102,5,1,5,99,0,1102,5,1,11,99,0"; Assert.That(testProgram.Process(program, 6), Is.EqualTo("102,5,1,5,99,0,1102,5,1,11,99,5")); }
public void Should_accept_immediate_mode_configuration_for_arg2() { var testProgram = new MultiplierProgram(new IntCodeValidator()); var program = "1102,5,1,5,99,0"; Assert.That(testProgram.Process(program), Is.EqualTo("1102,5,1,5,99,5")); }
public void Should_validate_op_code_is_two(string input) { var validator = new IntCodeValidator(); var m = new MultiplierProgram(validator); var ex = Assert.Throws <InvalidOpCodeException>(() => m.Process(input)); Assert.That(ex.Message, Is.EqualTo("Invalid input: op code (first integer)")); }
public void Should_valldate_input() { var validator = new ValidatorSpy(); var m = new MultiplierProgram(validator); Assert.Throws <Exception>(() => m.Process("abc")); Assert.That(validator.WasCalled, Is.True); }
public void Should_multiply_two_numbers_and_update_at_position(string input, string expected) { var m = new MultiplierProgram(new IntCodeValidator()); Assert.That(m.Process(input), Is.EqualTo(expected)); }
public void Should_validate_in_program_configuration(string input) { var m = new MultiplierProgram(new IntCodeValidator()); Assert.DoesNotThrow(() => m.Process(input)); }