Exemplo n.º 1
0
        public void Underlines_FromFirstToLastModifierUnit_IncludingAllUnitsInBetween(
            string unShuffledSentence)
        {
            Paragraph paragraph =
                DocumentContentHelper
                .GetParagraphFromWordDocument(unShuffledSentence);

            var modifierStrategy = new ModifierStrategy(new FakeModifierFormatter());

            // act
            var shufflerParagraph =
                modifierStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Text[] sentenceArray = shufflerParagraph.Descendants <Text>().ToArray();

            int firstModifierPosition = Array.FindIndex(
                sentenceArray, text => text.InnerText.StartsWith("MD"));

            int lastModifierPosition = Array.FindLastIndex(
                sentenceArray, text => text.InnerText == "MD") + 1;

            for (int index = 0; index < sentenceArray.Length; index++)
            {
                Text t = sentenceArray[index];

                if (index >= firstModifierPosition && index <= lastModifierPosition)
                {
                    Assert.That(t.Parent.InnerXml.Contains("<w:u w:val=\"single\" />"));
                }
            }
        }
Exemplo n.º 2
0
        private static void AssertReturnIsEqualToExpected(
            string input, string expected, IModifierFormatter modifierFormatter)
        {
            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(input);

            var modifierUnitStrategy = new ModifierStrategy(modifierFormatter);

            //  act
            var shuffledParagraph =
                modifierUnitStrategy.ShuffleSentenceUnit(paragraph);

            Assert.That(shuffledParagraph.InnerText,
                        Is.EqualTo(
                            expected));
        }
Exemplo n.º 3
0
        private static void AssertReturnIsEqualToExpected(
            string input, string expected)
        {
            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(input);

            var prenStrategy = new PrenStrategy();

            //  act
            var shuffledParagraph =
                prenStrategy.ShuffleSentenceUnit(paragraph);

            Assert.That(shuffledParagraph.InnerText,
                        Is.EqualTo(
                            expected));
        }
Exemplo n.º 4
0
        public void When_VB_VBA_PAST_Found_Move_TimerUnit_InFront(
            string unShuffledSentence, string output)
        {
            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var timerUnitStrategy = new TimerUnitStrategy();

            //  act
            var shufflerParagraph =
                timerUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            output));
        }
Exemplo n.º 5
0
        private static void AssertThatUnShuffledSentenceReturnsExpectedSentence(string unShuffledSentence,
                                                                                string expectedSentence)
        {
            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new AdverbUnitStrategy();

            // act
            var shufflerParagraph =
                clauserUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            expectedSentence));
        }
Exemplo n.º 6
0
        public void TimerUnits_Are_ShuffledInDescendingOrderOfTheirSerialNumber()
        {
            const string unShuffledSentence =
                "TM1this time TM2last year BKP.";

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var timerUnitStrategy = new TimerUnitStrategy();

            //  act
            var shufflerParagraph =
                timerUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            "TM2last year TM1this time BKP."));
        }
        public void ShuffleClauserUnits_when_clauserAtStartOfSentence_DontMoveIt()
        {
            const string unShuffledSentence =
                "CSbefore he VBhad a chance VBto speak BKP, PRENThe meeting VBwas over BKP.";

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new ClauserUnitStrategy(new ClauserUnitChecker());

            // act
            var shufflerParagraph =
                clauserUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            "CSbefore he VBhad a chance VBto speak BKP, PRENThe meeting VBwas over BKP."));
        }
        public void ShuffleClauserUnits_ToTheBeginningOfTheSentenceAndAddComma()
        {
            const string unShuffledSentence =
                "TMIn April and May BKP, CShowever BKP, PRENthe NNreport VBwasn’t ADJgood BKP.";

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new ClauserUnitStrategy(new ClauserUnitChecker());

            //  act
            var shufflerParagraph =
                clauserUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            "CShowever BKP, TMIn April and May BKP, PRENthe NNreport VBwasn’t ADJgood BKP."));
        }
        public void ShuffleClauserUnits_ToTheBeginningOfTheSentenceAndAddsComma_WhenSpaceElementBeforeComma(
            string sentenceFile, string expectation)
        {
            string unShuffledSentence = sentenceFile;

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new ClauserUnitStrategy(new ClauserUnitChecker());

            // act
            var shufflerParagraph =
                clauserUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            expectation));

            // multiple clauser units?

            // what if the bkp is a ? or !
        }