예제 #1
0
        public void Multiplication()
        {
            int[] sequence       = new int[] { 2, 3, 3, 3, 99 };
            int[] expectedResult = new int[] { 2, 3, 3, 9, 99 };

            _optCodeComputer.Output(ref sequence);

            sequence.Should().BeEquivalentTo(expectedResult);
        }
예제 #2
0
        public void Output()
        {
            int[] sequence = new int[] { 4, 1, 99 };

            var recorder    = output.ToComputationRecorder();
            var optComputer = new OptCodeComputer(recorder, 1);

            optComputer.Output(ref sequence);
        }
예제 #3
0
        public void Input()
        {
            int[]     sequence = new int[] { 3, 2, 0 };
            const int input    = 99;

            int[] expectedResult = new int[] { 3, 2, input };

            var recorder    = output.ToComputationRecorder();
            var optComputer = new OptCodeComputer(recorder, input);

            optComputer.Output(ref sequence);

            sequence.Should().BeEquivalentTo(expectedResult);
        }
예제 #4
0
        public void FromInput()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "input.txt";

            var input = Utilities.EmbeddedResource.Get(resourceName, assembly);

            var memory = input.Split(",")
                         .Select(int.Parse)
                         .ToArray();

            _optCodeComputer.Output(ref memory);

            var output = _instructions.First(i => i.Type == InstructionType.output);

            output.Output.Should().Contain("4283952");
        }