public Motor(string motorNumber, MotorFamily motorType, uint?displacement, string feature, string description) { MotorNumber = motorNumber; MotorType = motorType; Displacement = displacement; Feature = feature; Description = description; }
public void LoadMotorFamily_ShouldReturnCorrectResult(string cellText, MotorFamily expected) { var reader = new BaseSheetReader(); var actual = reader.LoadMotorFamily(cellText); Assert.Equal(expected, actual); }
static public Motor CreateMotor(MotorFamily family, int numberOfParts) { Motor result = new Motor (RandomPartNumber(), family, RandomDisplacement(), RandomFeature(), RandomDescription() ); for (int i = 0; i < numberOfParts; i++) { result.AddPart(AllParts[random.Next(0, AllParts.Count - 1)], RandomPositionNumber(), RandomQuantity()); } return(result); }
static public Motor CreateMotor(MotorFamily family) { return(CreateMotor(family, RandomNumberOfParts())); }
public IEnumerable <Motor> ReadSheetAndConvertForMotors() { ISheet sheet = Workbook.GetSheet(SheetName); List <Motor> motors = new List <Motor>(); List <Part> parts = new List <Part>(); for (int i = motorsRow; i <= sheet.LastRowNum; i++) { var row = sheet.GetRow(i); string designationCellText = LoadCellAsString(row.GetCell(motorsDesignationColumn)); string motorNumber = LoadPartNumber(row.GetCell(motorsColumn)); if (motorNumber == null) { continue; } uint? displacement = LoadDisplacement(designationCellText); string MotorType = LoadMotorType(designationCellText); MotorFamily motorFamily = LoadMotorFamily(designationCellText); string motorDescription = LoadCellAsString(row.GetCell(motorsDescriptionColumn)); Motor newMotor = new Motor(motorNumber, motorFamily, displacement, MotorType, motorDescription); motors.Add(newMotor); for (int j = partsColumn; j <= row.LastCellNum; j++) { var cell = row.GetCell(j); if (cell == null) { continue; } else if (String.IsNullOrWhiteSpace(cell.ToString())) { continue; } string partNumber = LoadPartNumber(sheet.GetRow(partsRow).GetCell(j)); string positionNumberTxt = LoadPositionNumber(sheet.GetRow(partsPositionNoRow).GetCell(j)); string designation = LoadPartDesignation(sheet.GetRow(partsDesignationRow).GetCell(j)); string description = LoadDescription(sheet.GetRow(partsDescriptionRow).GetCell(j)); uint quantity = LoadQuantity(row.GetCell(j)); uint positionNumber = 0; if (IsLawrencePart(positionNumberTxt)) { continue; } else { UInt32.TryParse(positionNumberTxt, out positionNumber); } if (!IsRecordCorrect(partNumber, positionNumber)) { newMotor.RemoveAllParts(); break; } else { //TODO: Instead of looking to the list it should be Dictionary Part partToAdd = parts.FirstOrDefault(p => p.PartNumber.Equals(partNumber)); if (partToAdd == null) { parts.Add(partToAdd = new Part(partNumber, designation, description)); } newMotor.AddPart(partToAdd, positionNumber, quantity); } } } return(motors); }