public void Should_GetAddScreen_When_AddScreen() { var element = new Element(20, 20); var mosaic = new Mosaic(); var screens = new List <Screen>(); for (int i = 1; i < 100; i++) { screens.Add(new Screen(300, 300)); } mosaic.AddNeighbor(screens[0]); //First screen node for (int i = 1; i < screens.Count; i++) { mosaic.AddNeighbor(screens[i - 1], screens[i], DirectionEnum.Right); } //Move element Screen 3 > Location > 620:100 element.Move(620, 100); var result = mosaic.WhereAreYou(element, screens[2]); Assert.Equal <int>(screens.Count, mosaic.Items.Count); Assert.Equal <int>(screens.Count * 300, mosaic.Dimension.Width); Assert.Equal <int>(1220, result.X); Assert.Equal <int>(100, result.Y); }
public void Should_AddNeighborOnlyOne_When_FormASquare() { var mosaic = new Mosaic(); var screen0 = new Screen(100, 200); var screen1 = new Screen(100, 200); var screen2 = new Screen(100, 200); var screen3 = new Screen(100, 200); var screen4 = new Screen(100, 200); mosaic.AddNeighbor(screen0); mosaic.AddNeighbor(screen0, screen1, DirectionEnum.Up); mosaic.AddNeighbor(screen0, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen0, screen3, DirectionEnum.Down); mosaic.AddNeighbor(screen0, screen4, DirectionEnum.Left); var maker = new Maker(mosaic.Items); maker.Init(); Assert.NotNull(mosaic); Assert.Equal(5, mosaic.Items.Count); Assert.Equal(300, maker.Dimension.Width); Assert.Equal(600, maker.Dimension.Height); }
public void Should_GetNodesTreePath_When_ExistNodesTopAndRight() { var mosaic = new Mosaic(); var screen1 = new Screen(100, 200, "screen1"); var screenTop1 = new Screen(100, 200, "screenTop1"); var screenTop2 = new Screen(100, 200, "screenTop2"); var screenRight1 = new Screen(100, 200, "screenRight1"); var screenRight2 = new Screen(100, 200, "screenRight2"); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screenRight1, DirectionEnum.Right); mosaic.AddNeighbor(screenRight1, screenRight2, DirectionEnum.Right); mosaic.AddNeighbor(screen1, screenTop1, DirectionEnum.Up); mosaic.AddNeighbor(screenTop1, screenTop2, DirectionEnum.Up); var maker = new Maker(mosaic.Items); maker.Init(); var nodes = maker.GetNodesTreePath(); Assert.NotNull(mosaic); Assert.Equal(5, mosaic.Items.Count); Assert.NotNull(nodes); Assert.Equal(screen1, nodes[0].Screen); Assert.Equal(screenTop1, nodes[1].Screen); Assert.Equal(screenTop2, nodes[2].Screen); Assert.Equal(screenRight1, nodes[3].Screen); Assert.Equal(screenRight2, nodes[4].Screen); }
public void Should_GetDimensionCorrect_When_AddThreeScreeenDistinctHeight() { var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); Assert.NotNull(mosaic); Assert.Equal(3, mosaic.Items.Count); Assert.Equal(500, mosaic.Dimension.Width); Assert.Equal(300, mosaic.Dimension.Height); Assert.Equal(0, mosaic.Items[0].DimensionMosaic.X); Assert.Equal(0, mosaic.Items[0].DimensionMosaic.Y); Assert.Equal(screen1.Dimension.Width, mosaic.Items[0].DimensionMosaic.Width); Assert.Equal(screen1.Dimension.Height, mosaic.Items[0].DimensionMosaic.Height); Assert.Equal(200, mosaic.Items[1].DimensionMosaic.X); Assert.Equal(0, mosaic.Items[1].DimensionMosaic.Y); Assert.Equal(screen2.Dimension.Width, mosaic.Items[1].DimensionMosaic.Width); Assert.Equal(screen2.Dimension.Height, mosaic.Items[1].DimensionMosaic.Height); Assert.Equal(300, mosaic.Items[2].DimensionMosaic.X); Assert.Equal(0, mosaic.Items[2].DimensionMosaic.Y); Assert.Equal(screen3.Dimension.Width, mosaic.Items[2].DimensionMosaic.Width); Assert.Equal(screen3.Dimension.Height, mosaic.Items[2].DimensionMosaic.Height); }
public void Should_GetDimensionMosaic_When_ExisteRightScreen() { var mosaic = new Mosaic(); var screen1 = new Screen(100, 200, "screen1"); var screenRight1 = new Screen(100, 200, "screenRight1"); var screenRight2 = new Screen(100, 200, "screenRight2"); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screenRight1, DirectionEnum.Right); mosaic.AddNeighbor(screenRight1, screenRight2, DirectionEnum.Right); var maker = new Maker(mosaic.Items); maker.Init(); Assert.NotNull(mosaic); Assert.Equal(3, mosaic.Items.Count); Assert.Equal(0, mosaic.Items[0].DimensionMosaic.X); Assert.Equal(0, mosaic.Items[0].DimensionMosaic.Y); Assert.Equal(screen1.Dimension.Width, mosaic.Items[0].DimensionMosaic.Width); Assert.Equal(screen1.Dimension.Height, mosaic.Items[0].DimensionMosaic.Height); Assert.Equal(100, mosaic.Items[1].DimensionMosaic.X); Assert.Equal(0, mosaic.Items[1].DimensionMosaic.Y); Assert.Equal(screenRight1.Dimension.Width, mosaic.Items[1].DimensionMosaic.Width); Assert.Equal(screenRight1.Dimension.Height, mosaic.Items[1].DimensionMosaic.Height); Assert.Equal(200, mosaic.Items[2].DimensionMosaic.X); Assert.Equal(0, mosaic.Items[2].DimensionMosaic.Y); Assert.Equal(screenRight2.Dimension.Width, mosaic.Items[2].DimensionMosaic.Width); Assert.Equal(screenRight2.Dimension.Height, mosaic.Items[2].DimensionMosaic.Height); }
public void Should_AddNeighborTwo_When_FormAStar() { var mosaic = new Mosaic(); var screen0 = new Screen(100, 200); var screen11 = new Screen(100, 200); var screen12 = new Screen(100, 200); var screen21 = new Screen(100, 200); var screen22 = new Screen(100, 200); var screen31 = new Screen(100, 200); var screen32 = new Screen(100, 200); var screen41 = new Screen(100, 200); var screen42 = new Screen(100, 200); mosaic.AddNeighbor(screen0); mosaic.AddNeighbor(screen0, screen11, DirectionEnum.Up); mosaic.AddNeighbor(screen11, screen12, DirectionEnum.Up); mosaic.AddNeighbor(screen0, screen21, DirectionEnum.Right); mosaic.AddNeighbor(screen21, screen22, DirectionEnum.Right); mosaic.AddNeighbor(screen0, screen31, DirectionEnum.Down); mosaic.AddNeighbor(screen31, screen32, DirectionEnum.Down); mosaic.AddNeighbor(screen0, screen41, DirectionEnum.Left); mosaic.AddNeighbor(screen41, screen42, DirectionEnum.Left); var maker = new Maker(mosaic.Items); maker.Init(); Assert.NotNull(mosaic); Assert.Equal(9, mosaic.Items.Count); Assert.Equal(500, maker.Dimension.Width); Assert.Equal(1000, maker.Dimension.Height); }
public void Should_AddScreenNeighbor_When_AddScreenNeighborRight() { var mosaic = new Mosaic(); var screen1 = new Screen(100, 200); var screen2 = new Screen(100, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); Assert.NotNull(mosaic); Assert.Equal(2, mosaic.Items.Count); }
public void Should_GetDimensionCorrect_When_AddTwoScreeenSameHeight() { var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); Assert.NotNull(mosaic); Assert.Equal(2, mosaic.Items.Count); Assert.Equal(400, mosaic.Dimension.Width); Assert.Equal(200, mosaic.Dimension.Height); }
public void Should_GetMosaicItemByScreen_When_ExistItem() { var element = new Element(50, 50); var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); var result = mosaic.GetItem(screen2); Assert.NotNull(result); Assert.Equal(result.Screen, screen2); }
public void Should_AddScreenLeft_When_ScreenNeighborLeftExist() { var mosaic = new Mosaic(); var screen1 = new Screen(100, 200); var screen2 = new Screen(100, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Left); var maker = new Maker(mosaic.Items); maker.Init(); Assert.NotNull(mosaic); Assert.Equal(2, mosaic.Items.Count); Assert.Equal(200, maker.Dimension.Width); Assert.Equal(200, maker.Dimension.Height); }
public void Should_GetMosaicItemById_When_NotExistItem() { var element = new Element(50, 50); var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); var screen4 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); var result = mosaic.GetItem(screen4.Id.ToString()); Assert.Null(result); }
public void Should_AddScreeen_When_AddOneScreeen() { var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); mosaic.AddNeighbor(screen1); Assert.NotNull(mosaic); Assert.Single(mosaic.Items); }
public void Should_ExistItemTrue_When_AScreenIsInMosaic() { var mosaic = new Mosaic(); var screen1 = new Screen(100, 200); mosaic.AddNeighbor(screen1); var exist = mosaic.ExistItem(screen1); Assert.Single(mosaic.Items); Assert.True(exist); }
public void Should_MosaicToScreenLocation_When_AElementMoveIntoScreen2( int mosaicX, int mosaicY, int screenX, int screenY, int screenIndex) { var element = new Element(80, 80); var screen1 = new Screen(680, 627); var screen2 = new Screen(682, 627); var mosaic = new Mosaic(); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); element.Move(mosaicX, mosaicY); var result = mosaic.MosaicToScreenLocation(element, mosaic.Items[screenIndex].Screen); Assert.Equal <int>(screenX, result.X); Assert.Equal <int>(screenY, result.Y); }
public void Should_ResizeScreenIntoMosaic_When_ResizeScreen() { var element = new Element(50, 50); var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); var result = mosaic.Resize(screen2, 100, 500); var item2Result = mosaic.GetItem(screen2.Id.ToString()); Assert.NotNull(result); Assert.Equal <int>(100, item2Result.Screen.Dimension.Width); Assert.Equal <int>(500, item2Result.Screen.Dimension.Height); }
public void Should_GetScreensEmpty_When_AElementIsNotAnyScreen() { var element = new Element(50, 50); var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); element.Move(999, 999); var result = mosaic.IsIn(element); Assert.NotNull(mosaic); Assert.Empty(result); }
public void Should_GetScreens_When_AElementIsInScreenLast() { var element = new Element(50, 50); var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); element.Move(350, 150); var result = mosaic.IsIn(element); Assert.NotNull(mosaic); Assert.Single(result); Assert.Equal <Guid>(screen3.Id, result[0].Id); }
public void Should_GetElementLocation_When_AElementMoveIntoScreenItemThree() { var element = new Element(50, 50); var mosaic = new Mosaic(); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 300); var screen3 = new Screen(200, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); //Move element Screen 2 > Location > 20:100 element.Move(175, 75); var result = mosaic.WhereAreYou(element, screen3); Assert.Equal <int>(475, result.X); Assert.Equal <int>(75, result.Y); }
public void Should_MosaicToScreenLocation_When_AElementMoveIntoScreen( int mosaicX, int mosaicY, int screenX, int screenY, int screenIndex) { var element = new Element(50, 50); var screen1 = new Screen(200, 200); var screen2 = new Screen(100, 200); var screen3 = new Screen(200, 200); var mosaic = new Mosaic(); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); //Move element Screen 2 > Location > 250:100 element.Move(mosaicX, mosaicY); var result = mosaic.MosaicToScreenLocation(element, mosaic.Items[screenIndex].Screen); Assert.Equal <int>(screenX, result.X); Assert.Equal <int>(screenY, result.Y); }
public void Should_GetNodesTreePath_When_ExistNodesRightOnly() { var mosaic = new Mosaic(); var screen1 = new Screen(100, 200); var screen2 = new Screen(100, 200); var screen3 = new Screen(100, 200); mosaic.AddNeighbor(screen1); mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right); mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right); var maker = new Maker(mosaic.Items); maker.Init(); var nodes = maker.GetNodesTreePath(); Assert.NotNull(mosaic); Assert.Equal(3, mosaic.Items.Count); Assert.NotNull(nodes); Assert.Equal(screen1, nodes[0].Screen); Assert.Equal(screen2, nodes[1].Screen); Assert.Equal(screen3, nodes[2].Screen); }
public Mosaic Create(string screenId, int width, int height, string connectionId) { var id = Guid.Parse(screenId); Screen screen = null; var mosaic = new Mosaic(); if (screen == null) { screen = new Screen(id, width, height); screen.SetConnectionId(connectionId); mosaic.AddNeighbor(screen); Apps.Add(mosaic); } return(mosaic); }