public GridBuilder() { _gridCellFactory = new Mock <IGridCellFactory>().Object; // default config WithGridSize(1); }
public GridBuilder WithGridSize(int size) { _gridSize = size; // SB - create grid with cells count 'count^2' and fill each cell with 1 triangle which has: // a name which matches has X,Y coordinates of cell e.g. 11, 12, 21, 22 (for 4 cell grid) // a set of fake vertex coords related to cell e.g. for cell 11 (11, 11, 11) var stubGridCellFactory = new Mock <IGridCellFactory>(); for (int gridCellX = 1; gridCellX <= size; gridCellX++) { for (int gridCellY = 1; gridCellY <= size; gridCellY++) { var stubGridCell = new Mock <IGridCell>(); var cellTriangles = new List <ITriangle>(); var coordinates = new Coordinates(gridCellX, gridCellY); var stubTriangle = new Mock <ITriangle>(); stubTriangle.SetupGet(x => x.Name).Returns($"{gridCellX}{gridCellY}"); stubTriangle.SetupGet(x => x.Vertices).Returns(new TriangularVertex(coordinates, coordinates, coordinates)); cellTriangles.Add(stubTriangle.Object); stubGridCell.SetupGet(x => x.Triangles).Returns(cellTriangles.AsReadOnly()); stubGridCellFactory.Setup(x => x.Create(It.Is <Coordinates>(x => x == coordinates), It.IsAny <IGrid>())).Returns(stubGridCell.Object); } } _gridCellFactory = stubGridCellFactory.Object; return(this); }
public Grid(IGridCellFactory gridCellFactory, int size) { _gridCellFactory = gridCellFactory ?? throw new ArgumentException(nameof(gridCellFactory)); Size = size; Generate(); }
public GridGenerator(IGridCellFactory gridCellFactory, AppConfig appConfig) { _gridCellFactory = gridCellFactory ?? throw new ArgumentException(nameof(gridCellFactory)); _appConfig = appConfig ?? throw new ArgumentException(nameof(appConfig)); }