public void Then_the_input_is_outputted(int input) { var testString = "3,0,4,0,99"; var memory = new IntcodeMemory(testString); var sut = new Intcode.Intcode(memory, input); sut.ProcessInstructions(); Assert.That(sut.Output, Is.EqualTo(input)); }
public void StatesAreUpdated(string initialState, string expectedEndState) { var memory = new IntcodeMemory(initialState); var sut = new Intcode.Intcode(memory); sut.ProcessInstructions(); var result = string.Join(",", memory.GetState()); Assert.That(result, Is.EqualTo(expectedEndState)); }
public void Then_correct_enum_is_returned(string input, OppCode expectedOppCode, Mode expectedMode0, Mode expectedMode1, Mode expectedMode2) { var memory = new IntcodeMemory(input); var intcode = new Intcode.Intcode(memory); var(oppCode, modes) = intcode.GetInstruction(); Assert.That(oppCode, Is.EqualTo(expectedOppCode)); Assert.That(modes[0], Is.EqualTo(expectedMode0)); Assert.That(modes[1], Is.EqualTo(expectedMode1)); Assert.That(modes[2], Is.EqualTo(expectedMode2)); }
public void Then_the_numbers_are_multiplied() { var testString = "1,9,10,3,2,3,11,0,99,30,40,50"; var memory = new IntcodeMemory(testString); var sut = new Intcode.Intcode(memory); sut.ProcessInstructions(); var result = memory.GetValue(0); var expected = 3500; Assert.That(result, Is.EqualTo(expected)); }
public void Then_answer() { var testFilePath = "..//..//..//TestData//day05.txt"; var initialState = File.ReadLines(testFilePath).First(); var memory = new IntcodeMemory(initialState); var intcodeComputer = new Intcode.Intcode(memory, 5); intcodeComputer.ProcessInstructions(); var result = intcodeComputer.Output(); Assert.That(result, Is.EqualTo(4283952)); }
public void Setup() { var testFilePath = "..//..//..//TestData//day02.txt"; var initialState = File.ReadLines(testFilePath).First(); _memory = new IntcodeMemory(initialState); _memory.SetValue(1, 12); _memory.SetValue(2, 2); var intCode = new Intcode.Intcode(_memory); intCode.ProcessInstructions(); }
public void Then_result_at_position_zero_is_correct() { var testFilePath = "..//..//..//TestData//day02.txt"; var initialState = File.ReadLines(testFilePath).First(); _memory = new IntcodeMemory(initialState); _intCode = new Intcode.Intcode(_memory); var nounVerb = _intCode.FindNounVerb(_expectedOutput); var result = _memory.GetValue(0); Assert.That(result, Is.EqualTo(_expectedOutput)); Assert.That(nounVerb, Is.EqualTo(4847)); }