예제 #1
0
 private void ResetLimit(MarkdownConnection mdConnection)
 {
     if (previousConnection == null || !ContainsInPreviousConnection(mdConnection))
     {
         maxPossibleType = MarkdownConnectionType.SingleAndDouble;
     }
 }
        public void TranslateConnections_TransformsConnection_IntoCorrectSelections(MarkdownConnectionType connectionType, MdSelectionType[] expectedSelections)
        {
            var residualStrengths = new[] { 1, 1 };
            var mdSelectedItems   = handlerConnections.TranslateConnections(new[] { new MarkdownConnection(0, 1, connectionType) },
                                                                            residualStrengths);

            mdSelectedItems.ElementAt(0).Selections.Should().BeEquivalentTo(expectedSelections,
                                                                            assertionOptions => assertionOptions.WithStrictOrdering());
        }
예제 #3
0
 private void UpdateMdLimitsType(MarkdownConnectionType type)
 {
     if (type == MarkdownConnectionType.SingleAndDouble || type == MarkdownConnectionType.Single)
     {
         maxPossibleType = MarkdownConnectionType.None;
     }
     else if (type == MarkdownConnectionType.Double)
     {
         maxPossibleType = MarkdownConnectionType.Single;
     }
 }
예제 #4
0
        public void Filter_ReturnsCorrectTypeItemOnSecondItem_WhenGetsTwoNestedItems(MarkdownConnectionType firstType, MarkdownConnectionType secondType, MarkdownConnectionType expectedType)
        {
            var firstConnection  = CreateMdConnection(0, 4, firstType);
            var secondConnection = CreateMdConnection(1, 2, secondType);

            filter.Filter(firstConnection);
            var filteredConnection = filter.Filter(secondConnection);


            filteredConnection.ConnectionType
            .Should()
            .Be(expectedType);
        }
예제 #5
0
 public MarkdownConnection(int firstIndex, int secondIndex, MarkdownConnectionType type)
 {
     RaiseIfIndexesAreIncorrect(firstIndex, secondIndex);
     if (firstIndex > secondIndex)
     {
         FirstIndex  = secondIndex;
         SecondIndex = firstIndex;
     }
     else
     {
         FirstIndex  = firstIndex;
         SecondIndex = secondIndex;
     }
     ConnectionType = type;
 }
예제 #6
0
        private void AddConnection(List <MdConvertedItemNotSafe> mdItems, int index, MarkdownConnectionType type)
        {
            var mdItem = mdItems[index];

            if (type == MarkdownConnectionType.SingleAndDouble)
            {
                mdItem.Selections.Add(MdSelectionType.Bold);
                mdItem.Selections.Add(MdSelectionType.Italic);
            }
            else if (type == MarkdownConnectionType.Single)
            {
                mdItem.Selections.Add(MdSelectionType.Italic);
            }
            else if (type == MarkdownConnectionType.Double)
            {
                mdItem.Selections.Add(MdSelectionType.Bold);
            }
        }
예제 #7
0
        public void Filter_ReturnsSameTypeItem_WhenGetsOnlyOneItem(int firstIndex, int secondIndex, MarkdownConnectionType type)
        {
            var mdConnection     = CreateMdConnection(firstIndex, secondIndex, type);
            var actualConnection = filter.Filter(mdConnection);

            actualConnection.ConnectionType.Should().Be(mdConnection.ConnectionType);
        }
예제 #8
0
        private MarkdownConnection CreateMdConnection(int firstIndex, int secondIndex, MarkdownConnectionType type)
        {
            var connection = new Connection(firstIndex, secondIndex, 10);

            return(new MarkdownConnection(connection, type));
        }
예제 #9
0
 public MarkdownConnection ChangeType(MarkdownConnectionType type)
 => new MarkdownConnection(FirstIndex, SecondIndex, type);
예제 #10
0
 public MarkdownConnection(Connection connection, MarkdownConnectionType type)
 {
     FirstIndex     = connection.FirstItemIndex;
     SecondIndex    = connection.SecondItemIndex;
     ConnectionType = type;
 }
        public void TranslateConnections_DoesNotChangeDirectionNonConnectedItems_WhenThereIsOneConnectionWithGivenType(MarkdownConnectionType connectionType)
        {
            var residualStrengths = new[] { 1, 2, 3, 5, 6, 7, 9 };
            var connection        = new MarkdownConnection(0, 1, connectionType);

            var mdConvertedItems = handlerConnections.TranslateConnections(new[] { connection }, residualStrengths);

            mdConvertedItems.Skip(2).Should().OnlyContain(x => x.Direction == Direction.None);
        }
        public void TranslateConnections_ChangesDirection_WhenThereIsOneConnectionWithGivenType(MarkdownConnectionType connectionType)
        {
            var residualStrengths = new[] { 1, 1, 1 };
            var connection        = new MarkdownConnection(0, 2, connectionType);

            var mdConvertedItems = handlerConnections.TranslateConnections(new[] { connection }, residualStrengths).ToList();

            mdConvertedItems[0].Direction.Should().Be(Direction.Right);
            mdConvertedItems[2].Direction.Should().Be(Direction.Left);
        }
예제 #13
0
        public void Convert_ReturnsCorrectConnectionType_WhenGetsCurrectStrengthConnection(int connectionStrength,
                                                                                           MarkdownConnectionType exptectedType)
        {
            var givenConnection = new Connection(0, 1, connectionStrength);

            converter.Convert(givenConnection);
        }