Beispiel #1
0
        [InlineData("R8,U5,L5,D3", "U7,R6,D4,L4", 6)] // example from website
        public void When_Intersection_Then_Distance_From_Origin_Should_Be_Set(string p1, string p2, int distance)
        {
            // Arrange
            var sut = new CircuitAnalyzer();

            // Act
            sut.AddVectors(p1);
            sut.AddVectors(p2);

            // Assert
            sut.DistanceBetweenOriginAndClosestIntersection.ShouldBe(distance);
        }
Beispiel #2
0
        public void When_Multiple_Wires_Should_Not_Throw()
        {
            // Arrange
            var sut   = new CircuitAnalyzer();
            var wire1 = "U2";
            var wire2 = "R1,U1,L1";

            // Act
            sut.AddVectors(wire1);
            sut.AddVectors(wire2);

            // Assert
            sut.GetLinesCrossedFromIndex(0, 1).ShouldBe(3);
        }
Beispiel #3
0
        public void When_intersections_then_smallest_path_is_correct()
        {
            // Arrange
            var sut   = new CircuitAnalyzer();
            var wire1 = "U5";
            var wire2 = "R1,U1,L2,U1,R2";

            // Act
            sut.AddVectors(wire1);
            sut.AddVectors(wire2);

            // Assert
            sut.SmallestPathLengthSumAtIntersection.ShouldBe(4);
        }
Beispiel #4
0
        public void When_Multiple_Intersections_Then_Distance_From_Origin_Should_Be_Correct()
        {
            // Arrange
            var sut   = new CircuitAnalyzer();
            var wire1 = "U5";
            var wire2 = "R1,U1,L2,U1,R2";

            // Act
            sut.AddVectors(wire1);
            sut.AddVectors(wire2);

            // Assert
            sut.DistanceBetweenOriginAndClosestIntersection.ShouldBe(1);
        }
Beispiel #5
0
        public void When_Vectors_Should_Not_Throw()
        {
            // Arrange
            var sut          = new CircuitAnalyzer();
            var vectorString = "D3";

            // Act
            sut.AddVectors(vectorString);

            // Assert
            sut.GetLinesCrossedFromIndex(0, -1).ShouldBe(1);
        }