Пример #1
0
 public void ThrowsComponentsCantBeLinkedExceptionIfComponentsAreOfIncorrectType()
 {
     BSManager.AddComponentWithNameAndRectangle(inputComponentName, new Rectangle(0, 0, width, height));
     BSManager.AddComponentWithNameAndRectangle(preprocessorComponentName, new Rectangle(width + distanceBetweenRects, 0, width, height));
     BSManager.LinkComponentsAtPoints(new Point(rnd.Next(width + distanceBetweenRects, 2 * width + distanceBetweenRects), rnd.Next(height)),
                                      new Point(rnd.Next(width), rnd.Next(height)));
 }
Пример #2
0
        public void LinksComponentsSuccessfullyIfEverythingIsGood()
        {
            BSManager.AddComponentWithNameAndRectangle(inputComponentName, new Rectangle(0, 0, width, height));
            BSBaseComponent input = BSManager.Components[0];

            BSManager.AddComponentWithNameAndRectangle(preprocessorComponentName, new Rectangle(width + distanceBetweenRects, 0, width, height));
            BSBaseComponent preprocessor = BSManager.Components[1];

            BSManager.LinkComponentsAtPoints(new Point(rnd.Next(width), rnd.Next(height)),
                                             new Point(rnd.Next(width + distanceBetweenRects, 2 * width + distanceBetweenRects), rnd.Next(height)));
            IList <BSBaseComponent> actualSuccs = BSManager.SuccessorsForComponent(input), actualPreds = BSManager.PredecessorsForComponent(preprocessor);

            Assert.AreEqual(1, actualSuccs.Count); Assert.AreEqual(1, actualPreds.Count);
            Assert.AreSame(preprocessor, actualSuccs[0]);
            Assert.AreSame(input, actualPreds[0]);
        }
 private void mainPictureBox_MouseUp(object sender, MouseEventArgs e)
 {
     if (imageBeforeDrag != null)
     {
         try
         {
             BSManager.LinkComponentsAtPoints(dragStartingPoint, e.Location);
         }
         catch (Exception exc)
         {
             if (exc is ComponentsCantBeLinkedException || exc is ArgumentException)
             {
                 (sender as PictureBox).Image = imageBeforeDrag;
             }
             else
             {
                 throw;
             }
         }
     }
     imageBeforeDrag = null;
 }