Пример #1
0
        public void Create_WhenHasSourceAndTarget_ShouldAddSourceSegmentToParagraphUnit()
        {
            // Arrange
            var testee = CreateTestee();

            var sourceSegmentMock = A.Fake <ISegment>();
            var targetSegmentMock = A.Fake <ISegment>();

            A.CallTo(() => _itemFactoryMock.CreateSegment(A <ISegmentPairProperties> .Ignored)).ReturnsNextFromSequence(sourceSegmentMock, targetSegmentMock);

            var textPropertiesMock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties(TheSourceValue)).Returns(textPropertiesMock);

            var textMock = A.Fake <IText>();

            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMock)).Returns(textMock);

            // Act
            testee.Create(TheSourcePath, TheSourceValue, TheTargetPath, TheTargetValue);

            // Assert
            A.CallTo(() => sourceSegmentMock.Add(textMock)).MustHaveHappened();
            A.CallTo(() => _paragraphUnitMock.Source.Add(sourceSegmentMock)).MustHaveHappened();
        }
Пример #2
0
        public void VisitSegment(ISegment segment)
        {
            var newSegment = _itemFactory.CreateSegment(segment.Properties);

            _currentContainer.Add(newSegment);
            _currentContainer = newSegment;

            VisitChildElements(segment);

            _currentContainer = newSegment.Parent;
        }
        public void VisitSegment(ISegment segment)
        {
            var segment2 = _itemFactory.CreateSegment(segment.Properties);

            _currentContainer.Add(segment2);
            _currentContainer = segment2;
            foreach (var current in segment)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = segment2.Parent;
        }
        public void SetUp()
        {
            _itemFactoryMock       = A.Fake <IDocumentItemFactory>();
            _propertiesFactoryMock = A.Fake <IPropertiesFactory>();

            _paragraphUnitMock = A.Fake <IParagraphUnit>();
            A.CallTo(() => _itemFactoryMock.CreateParagraphUnit(A <LockTypeFlags> .Ignored)).Returns(_paragraphUnitMock);

            _paragraphSourceMock = A.Fake <IParagraph>();
            A.CallTo(() => _paragraphUnitMock.Source).Returns(_paragraphSourceMock);

            _paragraphTargetMock = A.Fake <IParagraph>();
            A.CallTo(() => _paragraphUnitMock.Target).Returns(_paragraphTargetMock);

            _segmentPairPropertiesMock = A.Fake <ISegmentPairProperties>();
            A.CallTo(() => _itemFactoryMock.CreateSegmentPairProperties()).Returns(_segmentPairPropertiesMock);

            _translationOriginMmock = A.Fake <ITranslationOrigin>();
            A.CallTo(() => _itemFactoryMock.CreateTranslationOrigin()).Returns(_translationOriginMmock);

            _sourceSegment0Mock = A.Fake <ISegment>();
            _targetSegment0Mock = A.Fake <ISegment>();
            _sourceSegment1Mock = A.Fake <ISegment>();
            _targetSegment1Mock = A.Fake <ISegment>();
            _sourceSegment2Mock = A.Fake <ISegment>();
            _targetSegment2Mock = A.Fake <ISegment>();
            _sourceSegment3Mock = A.Fake <ISegment>();
            _targetSegment3Mock = A.Fake <ISegment>();
            A.CallTo(() => _itemFactoryMock.CreateSegment(A <ISegmentPairProperties> .Ignored))
            .ReturnsNextFromSequence(
                _sourceSegment0Mock, _targetSegment0Mock,
                _sourceSegment1Mock, _targetSegment1Mock,
                _sourceSegment2Mock, _targetSegment2Mock,
                _sourceSegment3Mock, _targetSegment3Mock
                );

            var textPropertiesMsgidMock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("message id")).Returns(textPropertiesMsgidMock);

            var textPropertiesMsgidPluralMock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("message id plural"))
            .Returns(textPropertiesMsgidPluralMock);

            var textPropertiesMsgstrMock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("message string"))
            .Returns(textPropertiesMsgstrMock);

            var textPropertiesMsgstr0Mock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("message string 0"))
            .Returns(textPropertiesMsgstr0Mock);

            var textPropertiesMsgstr1Mock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("message string 1"))
            .Returns(textPropertiesMsgstr1Mock);

            var textPropertiesMsgstr2Mock = A.Fake <ITextProperties>();

            A.CallTo(() => _propertiesFactoryMock.CreateTextProperties("message string 2"))
            .Returns(textPropertiesMsgstr2Mock);

            _textMsgidMock = A.Fake <IText>();
            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMsgidMock)).Returns(_textMsgidMock);

            _textMsgidPluralMock = A.Fake <IText>();
            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMsgidPluralMock)).Returns(_textMsgidPluralMock);

            _textMsgstrMock = A.Fake <IText>();
            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMsgstrMock)).Returns(_textMsgstrMock);

            _textMsgstr0Mock = A.Fake <IText>();
            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMsgstr0Mock)).Returns(_textMsgstr0Mock);

            _textMsgstr1Mock = A.Fake <IText>();
            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMsgstr1Mock)).Returns(_textMsgstr1Mock);

            _textMsgstr2Mock = A.Fake <IText>();
            A.CallTo(() => _itemFactoryMock.CreateText(textPropertiesMsgstr2Mock)).Returns(_textMsgstr2Mock);
        }