Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        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));
        }