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))); }
public void MyTestInitialize() { Rectangle componentRectangle = new Rectangle(0, 0, width, height); string randomComponentName = BSManager.ComponentsNamesDict.Keys.ElementAt(rnd.Next(BSManager.ComponentsNamesDict.Keys.Count)); BSManager.AddComponentWithNameAndRectangle(randomComponentName, componentRectangle); }
private void mainPictureBox_DragDrop(object sender, DragEventArgs e) { if (null != draggedImg) { Point mousePos = (sender as Control).PointToClient(new Point(e.X, e.Y)); Rectangle componentRect = new Rectangle(mousePos.X - draggedImg.Width / 2, mousePos.Y - draggedImg.Height / 2, draggedImg.Width, draggedImg.Height); _DrawComponentOnPictureBoxInRectangle(e, draggedImg, (sender as PictureBox), componentRect); BSManager.AddComponentWithNameAndRectangle(e.Data.GetData(DataFormats.StringFormat) as string, componentRect); draggedImg = null; } }
public void ThrowsKeyNotFoundException() { Random rnd = new Random(); string notPresentKey; while (BSManager.ComponentsNamesDict.ContainsKey(notPresentKey = Convert.ToString(rnd.Next()))) { ; } BSManager.AddComponentWithNameAndRectangle(notPresentKey, new Rectangle()); }
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]); }
public void AddsNewComponentCorrectly() { Random rnd = new Random(); string randomComponentName = BSManager.ComponentsNamesDict.Keys.ElementAt(rnd.Next(BSManager.ComponentsNamesDict.Keys.Count)); IComponentsFactory correspondingComponentFactory = BSManager.ComponentsNamesDict[randomComponentName]; Rectangle componentRectangle = new Rectangle(rnd.Next(), rnd.Next(), rnd.Next(), rnd.Next()); BSBaseComponent expectedComp = correspondingComponentFactory.NewComponent(componentRectangle); BSManager.AddComponentWithNameAndRectangle(randomComponentName, componentRectangle); IList <BSBaseComponent> actualCompsList = BSManager.Components; Assert.AreEqual(1, actualCompsList.Count); BSBaseComponent actualComp = actualCompsList.First(); Assert.AreEqual(expectedComp.GetType(), actualComp.GetType()); Assert.AreEqual(componentRectangle, actualComp.OnScreenRectangle); }
public void ThrowsArgumentNullException() { BSManager.AddComponentWithNameAndRectangle(null, new Rectangle()); }