public void ProcessParagraphUnit_WhenTargetPathIsNotStringToken_ShouldNotReplaceValueWithTargetText()
        {
            // Arrange
            var testee = CreateTestee();

            var targetTokenMock = A.Fake <IJToken>();

            A.CallTo(() => _rootTokenMock.SelectToken(TheTargetPath)).Returns(targetTokenMock);

            // Act
            testee.ProcessParagraphUnit(_paragraphUnitMock);

            // Assert
            A.CallToSet(() => _targetValueMock.Value).To(TheTargetText).MustNotHaveHappened();
        }
        public void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
        {
            var locationContextInfo = paragraphUnit.Properties.Contexts.Contexts[1];
            var sourcePath          = locationContextInfo.GetMetaData(ContextKeys.SourcePath);
            var targetPath          = locationContextInfo.GetMetaData(ContextKeys.TargetPath);

            if (string.IsNullOrEmpty(targetPath))
            {
                targetPath = sourcePath;
            }

            var targetToken = _rootToken.SelectToken(targetPath);

            if (targetToken == null)
            {
                throw new Exception($"Cannot find token with path {targetPath}");
            }

            if (targetToken.Type != JTokenType.String)
            {
                return;
            }

            var targetText = _segmentReader.GetTargetText(paragraphUnit.SegmentPairs);

            var value = targetToken.Value;

            if (value == null)
            {
                return;
            }

            value.Value = targetText;
        }