예제 #1
0
        public void TestPartTwo1()
        {
            StringInput input    = new StringInput("U");
            Day2Solver  solution = new Day2Solver();

            solution.GetSolution(input).SecondPart.Should().Be("5");
        }
예제 #2
0
        public void TestPartTwo2()
        {
            StringInput input    = new StringInput("ULL", "RRDDD", "LURDL", "UUUUD");
            Day2Solver  solution = new Day2Solver();

            solution.GetSolution(input).SecondPart.Should().Be("5DB3");
        }
예제 #3
0
        public void TestPartOne1()
        {
            StringInput input    = new StringInput("ULL", "RRDDD", "LURDL", "UUUUD");
            Day2Solver  solution = new Day2Solver();

            solution.GetSolution(input).FirstPart.Should().Be("1985");
        }
예제 #4
0
        public void TestPartOne4()
        {
            StringInput input    = new StringInput(@"");
            Day2Solver  solution = new Day2Solver();

            solution.GetSolution(input).FirstPart.Should().Be("5");
        }
예제 #5
0
        public void Day2Actual()
        {
            var solver = new Day2Solver(new FileReader(), new Day2Solver.DataParser(), new Day2Solver.PasswordChecker());
            var result = solver.Solve(@"Data\Day2.txt");

            Assert.AreEqual(517, result);
        }
예제 #6
0
        public void Day2SolverTest()
        {
            //Arrange
            var passwordCheckerMock = new Mock <Day2Solver.IPasswordChecker>();
            var dataParserMock      = new Mock <Day2Solver.IDataParser>();
            var fileReaderMock      = new Mock <IReader>();
            var daySolver           = new Day2Solver(fileReaderMock.Object, dataParserMock.Object, passwordCheckerMock.Object);
            var testPath            = "blaat";
            var parsedTestData      = new List <string> {
                "test", "data"
            };
            var mockSpecs = new List <Day2Solver.PasswordSpecification>();

            fileReaderMock.Setup(a => a.ReadText(testPath)).Returns("test\ndata");
            var expectedValue = 1337;

            passwordCheckerMock.Setup(a => a.HowManyPasswordAreCorrect(mockSpecs)).Returns(expectedValue);

            //Act
            var result = daySolver.Solve(testPath);

            //Assert
            fileReaderMock.Verify(a => a.ReadText(testPath), Times.Once);
            dataParserMock.Verify(a => a.Parse(parsedTestData), Times.Once);
            passwordCheckerMock.Verify(a => a.HowManyPasswordAreCorrect(mockSpecs), Times.Once);
            Assert.AreEqual(expectedValue, result);
        }
예제 #7
0
        public void TestPart2Solution(string inputFile, int expected)
        {
            // Arrange
            long[] input = Helpers.ReadIntCodeInput($"../../../{inputFile}");

            // Act
            var result = Day2Solver.Part2Solution(input);

            // Assert
            Assert.Equal(expected, result);
        }
예제 #8
0
        public void TestPart1Solution(string inputFile, int expected)
        {
            // Arrange
            long[] input = Helpers.ReadIntCodeInput($"../../../{inputFile}");
            if (inputFile.Contains("puzzle.input"))
            {
                // Set position 1 and 2 values to IntCode computer error state 1202
                input[1] = 12;
                input[2] = 2;
            }

            // Act
            var result = Day2Solver.Part1Solution(input);

            // Assert
            Assert.Equal(expected, result);
        }
예제 #9
0
        static bool testDay2()
        {
            Day2Solver day2Solver = new Day2Solver("../PuzzleInputs/Day2/input.txt");
            var        output     = day2Solver.Solve() as TwoPartPuzzleOutput;

            if ((long)output.Part1.Output != 5928)
            {
                System.Console.WriteLine($"Day2 Part1 solver solution is {output.Part1.Output} when it should have been 5928");
                return(false);
            }

            if ((string)output.Part2.Output != "bqlporuexkwzyabnmgjqctvfs")
            {
                System.Console.WriteLine($"Day2 Part2 solver solution is {output.Part2.Output} when it should have been 'bqlporuexkwzyabnmgjqctvfs");
                return(false);
            }

            return(true);
        }
예제 #10
0
 public void SetUp()
 {
     _solver = new Day2Solver();
     _parser = new Day2Parser();
 }
예제 #11
0
 public void SetUp()
 {
     _solver = new Day2Solver();
 }