Exemple #1
0
        public void GivenWord_WhenInvokingExecute_ThenWordIsReturned()
        {
            //Arrange
            var left        = 10;
            var top         = 20;
            var width       = 40;
            var height      = 15;
            var returnCoord = new Coordinate(0, 0, 0, 0);

            _relativeCoords.Setup(z => z.Execute(
                                      It.Is <AzureVisionApiSimpleOcrSdk.Model.Rectangle>(x => x.Height == height && x.Width == width && x.Top == top && x.Left == left),
                                      100, 200)).Returns(returnCoord);

            var wordValue = "MyTestWord";

            var word = new AzureVisionApiSimpleOcrSdk.Model.Word
            {
                BoundingBox = $"{left},{top},{width},{height}",
                Text        = wordValue
            };

            //Act
            var result = _target.Execute(word, _imgWidth, _imgHeight);

            //Assert
            result.Value.Should().Be(wordValue);
            result.Coordinate.Should().Be(returnCoord);
        }
Exemple #2
0
        public IWord Execute(Word word, int imgWidth, int imgHeight)
        {
            if (word == null)
            {
                throw new ArgumentNullException(nameof(word));
            }

            var coord = _createRelativeCoordinate.Execute(word.Rectangle, imgWidth, imgHeight);

            return(new OcrMetadata.Model.Word(coord, word.Text));
        }