public void InputTest2_EqualTo_False()
        {
            // Arrange
            var inputParam = new Queue <int>(new int[] { 8 });

            // Act
            var intcodeComputer = new IC.IntcodeComputer(Version.V3);
            var outputValues    = intcodeComputer.ProcessIntcodes(_inputTest2, inputParam);

            // Assert
            Assert.IsFalse(outputValues.FirstOrDefault() == 1);
        }
        public void InputTest7_GreaterThan_True()
        {
            // Arrange
            var inputParam = new Queue <int>(new int[] { 9 });

            // Act
            var intcodeComputer = new IC.IntcodeComputer(Version.V3);
            var outputValues    = intcodeComputer.ProcessIntcodes(_inputTest7, inputParam);

            // Assert
            Assert.IsTrue(outputValues.FirstOrDefault() == 1001);
        }
Exemple #3
0
        public void InputTest3_ValidInput_True()
        {
            // Arrange
            var inputData = new List <int> {
                3, 31, 3, 32, 1002, 32, 10, 32, 1001, 31, -2, 31, 1007, 31, 0, 33, 1002, 33, 7, 33, 1, 33, 31, 31, 1, 32, 31, 31, 4, 31, 99, 0, 0, 0
            };
            var phaseSettings = new Queue <int>(new int[] { 1, 0, 4, 3, 2 });

            // Act
            var intCodeComputer = new IC.IntcodeComputer(Version.V3);
            var resultA         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), 0 })).SingleOrDefault();
            var resultB         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultA })).SingleOrDefault();
            var resultC         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultB })).SingleOrDefault();
            var resultD         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultC })).SingleOrDefault();
            var resultE         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultD })).SingleOrDefault();

            // Assert
            Assert.IsTrue(resultE == 65210);
        }
Exemple #4
0
        public void InputTest2_ValidInput_True()
        {
            // Arrange
            var inputData = new List <int> {
                3, 23, 3, 24, 1002, 24, 10, 24, 1002, 23, -1, 23, 101, 5, 23, 23, 1, 24, 23, 23, 4, 23, 99, 0, 0
            };
            var phaseSettings = new Queue <int>(new int[] { 0, 1, 2, 3, 4 });

            // Act
            var intCodeComputer = new IC.IntcodeComputer(Version.V3);
            var resultA         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), 0 })).SingleOrDefault();
            var resultB         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultA })).SingleOrDefault();
            var resultC         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultB })).SingleOrDefault();
            var resultD         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultC })).SingleOrDefault();
            var resultE         = intCodeComputer.ProcessIntcodes(inputData, new Queue <int>(new int[] { phaseSettings.Dequeue(), resultD })).SingleOrDefault();

            // Assert
            Assert.IsTrue(resultE == 54321);
        }