private void MakeFactionCores(IMapManager mapManager, IFactionManager factionManager) { var faction = factionManager.GetPlayerFaction(); faction.ModifyResource(new Dictionary <ResourceType, int>() { { ResourceType.Gold, 10 }, { ResourceType.Food, 10 }, { ResourceType.Stone, 10 }, { ResourceType.Wood, 10 }, }); var coreCell = mapManager.GetRandomCell((cell) => cell.Terrain.Type == TerrainType.Grass); faction.StructureManager.AddStructure(StructureDefinition.StructureType.Core, coreCell.Coord); var roadRect = coreCell.NonNullNeighbors; foreach (var cell in roadRect) { faction.StructureManager.AddStructure(StructureDefinition.StructureType.Road, cell.Coord); } foreach (var roadStub in CellExtensions.GetCardinalsOutsideRectangle(roadRect)) { faction.StructureManager.AddStructure(StructureDefinition.StructureType.Road, roadStub.Coord); } factionManager.MoveToNextTurn(); }
public static void GetAvailabilityCheckMessageOrNull___Should_throw_ArgumentNullException___When_parameter_cell_is_null() { // Arrange, Act var actual = Record.Exception(() => CellExtensions.GetAvailabilityCheckMessageOrNull(null)); // Assert actual.AsTest().Must().BeOfType <ArgumentNullException>(); }
public static void GetValidationStatus___Should_throw_ArgumentNullException___When_parameter_cell_is_null() { // Arrange, Act var actual = Record.Exception(() => CellExtensions.GetValidationStatus(null)); // Assert actual.AsTest().Must().BeOfType <ArgumentNullException>(); }
public static void GetWidthInPixels___Should_throw_ArgumentNullException___When_parameter_cell_is_null() { // Arrange, Act var actual = Record.Exception(() => CellExtensions.GetWidthInPixels(null)); // Assert actual.Should().BeOfType <ArgumentNullException>(); actual.Message.Should().Contain("cell"); }
public static void ToFlatRow___Should_throw_ArgumentNullException___When_parameter_cell_is_null() { // Arrange, Act var actual = Record.Exception(() => CellExtensions.ToFlatRow(null)); // Assert actual.AsTest().Must().BeOfType <ArgumentNullException>(); actual.Message.AsTest().Must().ContainString("cell"); }
public void GetValue_BooleanTests(string strValue, bool?expected) { //Given _cell.Setup(x => x.ToString()).Returns(strValue); //When var value = CellExtensions.GetValue(_cell.Object, new FieldConfig { Type = "boolean" }); //Then value.Should().Be(expected); }
public void GetValue_Numeric_WhenTypeIsNotNumeric_ReturnsValidNumeric(string strValue, double?expected) { //Given _cell.Setup(x => x.ToString()).Returns(strValue); _cell.SetupGet(x => x.CellType).Returns(CellType.String); //When var value = CellExtensions.GetValue(_cell.Object, new FieldConfig { Type = "numeric" }); //Then value.Should().Be(expected); }
public void GetValue_NumericTest(string strValue, double?expected) { //Givend _cell.Setup(x => x.ToString()).Returns(strValue); _cell.SetupGet(x => x.CellType).Returns(CellType.Numeric); _cell.SetupGet(x => x.NumericCellValue).Returns(expected.Value); //When var value = CellExtensions.GetValue(_cell.Object, new FieldConfig { Type = "numeric" }); //Then value.Should().Be(expected); }
public void GetValue_WhenDateFormatIsInvalid_ReturnsInvalidDate() { //Given _cell.Setup(x => x.ToString()).Returns("xxx"); //When var value = CellExtensions.GetValue(_cell.Object, new FieldConfig { Type = "date", Validations = new ValidationOptions { } }); //Then value.Should().BeOfType(typeof(DateResult)); }
/// <summary> /// Looks up the column letter required for a specified worksheet column index (1=A) /// </summary> /// <param name="columnIndex">The index of the column</param> /// <returns>The letter representing the column</returns> public string GetColumnLetter(uint columnIndex) { string columnLetter = null; if (this.columnLetterStore.ContainsKey(columnIndex)) { columnLetter = this.columnLetterStore[columnIndex]; } else { columnLetter = CellExtensions.GetColumnLetter(columnIndex); this.columnLetterStore.Add(columnIndex, columnLetter); } return(columnLetter); }
public void GetValue_DateTests(string strDate, string[] formats, DateResult expected) { //Given _cell.Setup(x => x.ToString()).Returns(strDate); //When var value = CellExtensions.GetValue(_cell.Object, new FieldConfig { Type = "date", Validations = new ValidationOptions { Formats = formats } }); //Then value.Should().BeEquivalentTo(expected); }
/// <summary> /// Private ctor. Prevents public construction.<br/> /// Loads the model from the supplied <see cref="DefinedName"/> /// </summary> /// <param name="wb">The workbool</param> /// <param name="definedName">The named range</param> private DefinedNameModel(Workbook wb, DefinedName definedName) { this.IsDefined = wb.BreakDownDefinedName(definedName, ref worksheetName, ref rowStart, ref rowEnd, ref colStart, ref colEnd); if (this.IsDefined) { var wsPart = wb.GetWorksheetPartByName(worksheetName); this.Worksheet = wsPart.Worksheet; this.SheetData = this.Worksheet.GetFirstChild <SheetData>(); //get cells to be cloned according to the specified rows and columns this.Cells = this.SheetData.Descendants <DocumentFormat.OpenXml.Spreadsheet.Cell>().Where(c => CellExtensions.GetRowIndex(c.CellReference) >= rowStart && CellExtensions.GetRowIndex(c.CellReference) <= rowEnd && CellExtensions.GetColumnIndex(c.CellReference) >= colStart && CellExtensions.GetColumnIndex(c.CellReference) <= colEnd) .ToList <DocumentFormat.OpenXml.Spreadsheet.Cell>(); } }
/// <summary> /// Get a cell within the range given a 0 based row index and 0 based column index within that range. /// </summary> /// <param name="row"></param> /// <param name="col"></param> /// <returns></returns> public Cell GetCell(uint col, uint row) { string cellReference = CellExtensions.GetCellReference((this.ColStart + col), (this.RowStart + row)); return(this.Cells.FirstOrDefault(c => c.CellReference == cellReference)); }