public async Task DeleteShapeTest()
        {
            //Arrange
            await repoQ.AddQuoteAsync(quote2);

            (await repoS.Shapes).Add(shape2);

            //Act
            ViewResult view = (ViewResult)await controllerQ.DeleteShape(2, 2, "ReviewOpen");

            DeleteShape dS = (DeleteShape)view.Model;

            //Assert
            Assert.Equal(quote2, dS.Quote);
            Assert.Equal(shape2, dS.Shape);
            Assert.Equal("ReviewOpen", dS.ReturnUrl);
        }
        public async Task DeleteShapePostTest()
        {
            //Arrange
            DeleteShape dS = new DeleteShape
            {
                QuoteID   = 2,
                ShapeID   = 2,
                ReturnUrl = "ReviewOpen"
            };
            await repoQ.AddQuoteAsync(quote2);

            (await repoS.Shapes).Add(shape2);
            int shapeAmt = (await repoS.Shapes).Count;

            //Act
            await controllerQ.DeleteShape(dS);

            //Assert
            Assert.Equal(shapeAmt - 1, (await repoS.Shapes).Count);
        }
Exemple #3
0
        /// <summary>
        /// Evaluates the lines we have in the buffer
        /// </summary>
        /// <param name="lines">Lines</param>
        /// <remarks>
        /// We keep a buffer of lines. If a list of lines cannot be
        /// evaluated we wait for another second or so to allow for more lines.
        /// When that times out and no shape can be determined, then
        /// we clear the buffer.
        /// </remarks>
        private void EvaluateLines(List <Line> lines)
        {
            _clearTTL = _clearTTLResetValue;
            _buffer.AddRange(lines);

            var result = _patternEvaluator.Evaluate(_buffer);

            if (!result.IsValid)
            {
                return;
            }

            Debug.WriteLine("evaluation succeeded: " + result.Key);

            switch (result.Key)
            {
            case "button":
                var rectShape = new RectangleShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(rectShape));
                _recognizerCanvasNode.Clear();
                break;

            case "image":
                var imageShape = new ImageShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(imageShape));
                _recognizerCanvasNode.Clear();
                break;

            case "text":
                var textShape = new TextShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(textShape));
                _recognizerCanvasNode.Clear();
                break;

            case "entry":
                var entryShape = new EntryShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(entryShape));
                _recognizerCanvasNode.Clear();
                break;

            case "lineoftext":

                var lineoftext = new LineOfTextShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(lineoftext));
                _recognizerCanvasNode.Clear();
                break;


            case "delete":
                var deleteShape = new DeleteShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };

                var victims = IsShapeOverOtherShapes(deleteShape);
                foreach (var victim in victims)
                {
                    _shapeNode.RemoveChild(victim);
                }
                _recognizerCanvasNode.Clear();
                break;
            }

            _canvasNode.Clear();
            _buffer.Clear();
        }