public void AssertExpected(LotDefect defect) { Assert.AreEqual(DefectType, defect.DefectType); Assert.AreEqual(Description, defect.Description); if (Resolution) { Assert.IsNotNull(defect.Resolution); } else { Assert.IsNull(defect.Resolution); } }
public static LotDefect AddNewDefect(this Lot lot, DefectTypeEnum defectType, string description) { var nextDefectId = lot.LotDefects.Any() ? lot.LotDefects.Max(d => d.DefectId) + 1 : 1; var newDefect = new LotDefect { LotDateCreated = lot.LotDateCreated, LotDateSequence = lot.LotDateSequence, LotTypeId = lot.LotTypeId, DefectId = nextDefectId, DefectType = defectType, Description = description, }; lot.LotDefects.Add(newDefect); return(newDefect); }
internal static LotDefect SetValues(this LotDefect lotDefect, ILotKey lotKey = null, DefectTypeEnum?defectType = null) { if (lotKey != null) { lotDefect.Lot = null; lotDefect.LotDateCreated = lotKey.LotKey_DateCreated; lotDefect.LotDateSequence = lotKey.LotKey_DateSequence; lotDefect.LotTypeId = lotKey.LotKey_LotTypeId; } if (defectType != null) { lotDefect.DefectType = (DefectTypeEnum)defectType; } return(lotDefect); }
public static LotDefectResolution ResolveDefect(this LotDefect lotDefect, IEmployeeKey employee, ResolutionTypeEnum?resolutionType = null, string resolutionDescription = null) { if (lotDefect.Resolution != null) { throw new Exception(string.Format("LotDefect[{0}] already has resolution.", new LotKey(lotDefect))); } var resolution = new LotDefectResolution { EmployeeId = employee.EmployeeKey_Id, TimeStamp = DateTime.UtcNow, LotDateCreated = lotDefect.LotKey_DateCreated, LotDateSequence = lotDefect.LotKey_DateSequence, LotTypeId = lotDefect.LotKey_LotTypeId, DefectId = lotDefect.DefectId, ResolutionType = resolutionType ?? ResolutionTypeEnum.AcceptedByUser, Description = resolutionDescription ?? "Resolved by user in Access." }; lotDefect.Resolution = resolution; return(resolution); }
public static bool UpdateLot(Lot newLot, SerializableLot deserialized, bool tested, out List <LotAttributeDefect> attributeDefects) { if (deserialized == null) { newLot.Attributes = new List <LotAttribute>(); newLot.LotDefects = new List <LotDefect>(); attributeDefects = new List <LotAttributeDefect>(); return(false); } if (deserialized.LotIdentifiable != null) { newLot.EmployeeId = deserialized.LotIdentifiable.EmployeeKey.EmployeeKeyId; newLot.TimeStamp = deserialized.LotIdentifiable.TimeStamp; } var newAttributeDefects = new List <LotAttributeDefect>(); var attributeNameKeyParser = new AttributeNameKey(); var employeeKeyParser = new EmployeeKey(); newLot.Hold = deserialized.HoldType; newLot.HoldDescription = deserialized.HoldDescription; newLot.Attributes = deserialized.Attributes.Select(a => { var nameKey = attributeNameKeyParser.Parse(a.NameKey); var employeeKey = employeeKeyParser.Parse(a.EmployeeKey); return(new LotAttribute { Lot = newLot, TimeStamp = a.TimeStamp, EmployeeId = employeeKey.EmployeeKey_Id, LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, AttributeShortName = nameKey.AttributeNameKey_ShortName, AttributeValue = a.Value, AttributeDate = a.DateTested.Date, Computed = a.Computed ?? !tested }); }).ToList(); var defectId = 0; newLot.LotDefects = deserialized.Defects.Select(d => { DefectTypeEnum defectType; if (!DefectTypeEnum.TryParse(d.DefectType, out defectType)) { throw new Exception(string.Format("Could not parse DefectTypeEnum[{0}]", d.DefectType)); } var resolutionType = default(ResolutionTypeEnum); if (d.DefectResolution != null) { if (!ResolutionTypeEnum.TryParse(d.DefectResolution.ResolutionType, out resolutionType)) { throw new Exception(string.Format("Could not parse ResolutionTypeEnum[{0}]", d.DefectResolution.ResolutionType)); } } defectId += 1; var defect = new LotDefect { LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, DefectType = defectType, Description = d.Description, Resolution = d.DefectResolution == null ? null : new LotDefectResolution { EmployeeId = employeeKeyParser.Parse(d.DefectResolution.EmployeeKey).EmployeeKey_Id, TimeStamp = d.DefectResolution.TimeStamp, LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, ResolutionType = resolutionType, Description = d.DefectResolution.Description, } }; if (d.AttributeDefect != null) { var nameKey = attributeNameKeyParser.Parse(d.AttributeDefect.NameKey); newAttributeDefects.Add(new LotAttributeDefect { LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, AttributeShortName = nameKey.AttributeNameKey_ShortName, OriginalAttributeValue = d.AttributeDefect.Value, OriginalAttributeMinLimit = d.AttributeDefect.Min, OriginalAttributeMaxLimit = d.AttributeDefect.Max, LotDefect = defect }); } return(defect); }).ToList(); attributeDefects = newAttributeDefects; return(true); }