public void Clears_missing_attribute_values() { //Arrange var lot = new tblLot { Ash = 11, AToxin = 22, Gluten = 33 }; var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.IsNotNull(lot.AvgAsta); Assert.IsNotNull(lot.AvgScov); Assert.IsNotNull(lot.Scan); Assert.IsNull(lot.Ash); Assert.IsNull(lot.AToxin); Assert.IsNull(lot.Gluten); }
public void Returns_false_and_no_LotStat_will_have_been_set_it_no_unresolved_InHouseContamination_defects_exist() { //Arrange var lotWithNoDefects = new Lot { LotDefects = new LotDefect[0] }; var lotWithResolvedDefects = new Lot { LotDefects = new[] { BuildLotDefect(DefectTypeEnum.InHouseContamination, true), BuildLotDefect(DefectTypeEnum.InHouseContamination, true) } }; var oldLot = new tblLot { LotStat = null }; //Act-Assert Assert.IsFalse(LotSyncHelper.SetInHouseContamination(oldLot, lotWithNoDefects)); Assert.IsNull(oldLot.LotStat); Assert.IsFalse(LotSyncHelper.SetInHouseContamination(oldLot, lotWithResolvedDefects)); Assert.IsNull(oldLot.LotStat); }
public void Returns_false_and_LotStat_will_not_have_been_set_if_no_LotAttributes_or_defects_exist() { var oldLot = new tblLot(); Assert.IsFalse(LotSyncHelper.SetProductSpecDefectStat(oldLot, null, null, null)); Assert.IsNull(oldLot.LotStat); }
private static void UpdateOldLot(tblLot oldLot, Lot newLot, Customer customer, bool completedOverride, bool updateSerializationOnly) { if (!updateSerializationOnly) { if (customer != null) { oldLot.Company_IA = customer.Company.Name; } oldLot.Notes = newLot.Notes; oldLot.PurchOrder = newLot.PurchaseOrderNumber; oldLot.ShipperNum = newLot.ShipperNumber; if (string.IsNullOrWhiteSpace(oldLot.Company_IA) || newLot.Vendor != null) { oldLot.Company_IA = newLot.Vendor == null ? null : newLot.Vendor.Name; } LotSyncHelper.SetLotAttributes(oldLot, newLot.Attributes.ToList()); LotSyncHelper.SetTestData(oldLot, newLot); LotSyncHelper.SetLotStat(oldLot, newLot, completedOverride, newLot.ChileLot == null ? null : newLot.ChileLot.ChileProduct.ProductAttributeRanges.ToList()); } oldLot.Serialized = SerializableLot.Serialize(newLot); }
private static void TestInHouseContamination(LotStat expected, string description) { tblLot oldLot; Lot newLot; ArrangeLots(description, out oldLot, out newLot); Assert.IsTrue(LotSyncHelper.SetInHouseContamination(oldLot, newLot)); Assert.AreEqual((int)expected, oldLot.LotStat); }
public void Returns_true_and_LotStat_will_have_been_set_as_expected_for_ProductSpec_defect() { var oldLot = new tblLot(); Assert.IsTrue(LotSyncHelper.SetProductSpecDefectStat(oldLot, null, null, new List <IAttributeDefect> { GetLotStatHelperTests.BuildProductSpecDefect(StaticAttributeNames.H2O, 1, 2, 3, false) })); Assert.AreEqual((int)LotStat.Low_Water, oldLot.LotStat); }
public void Returns_true_and_LotStat_will_have_been_set_with_Notes_as_expected_for_an_unmatched_description() { tblLot oldLot; Lot newLot; const string description = "dark hard stuff with soft smoke"; ArrangeLots(description, out oldLot, out newLot); Assert.IsTrue(LotSyncHelper.SetInHouseContamination(oldLot, newLot)); Assert.AreEqual((int)LotStat.See_Desc, oldLot.LotStat); Assert.AreEqual(description, oldLot.Notes); }
public void UpdateOldLotAttributes(ILotKey lotKey, List <LotAttribute> newLotAttributes) { var lotNumber = LotNumberBuilder.BuildLotNumber(lotKey); var oldLot = _oldContext.tblLots .Include(l => l.tblLotAttributeHistory) .FirstOrDefault(l => l.Lot == lotNumber); if (oldLot == null) { throw new Exception(string.Format("Could not find tblLot[{0}]", lotNumber)); } SyncProductionBatchPickedInventoryHelper.SetLotBatchAttributes(oldLot, newLotAttributes); LotSyncHelper.SetLotAttributes(oldLot, newLotAttributes); }
public void Returns_false_and_LotStat_will_not_have_been_set_if_no_defects_of_ProductSpec_type_exist() { var oldLot = new tblLot(); Assert.IsFalse(LotSyncHelper.SetProductSpecDefectStat(oldLot, null, null, new List <IAttributeDefect> { new LotAttributeDefect { LotDefect = new LotDefect { DefectType = DefectTypeEnum.BacterialContamination }, } })); Assert.IsNull(oldLot.LotStat); }
public void IfAllAttributeTestDatesAreMinDateValue_TestDateIsNull() { // arrange var lot = new tblLot(); var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0, DateTime.MinValue); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f, DateTime.MinValue); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0, DateTime.MinValue); var newLot = new Lot { Attributes = new[] { asta, scoville, scan } }; // act LotSyncHelper.SetTestData(lot, newLot); // assert Assert.AreEqual(null, lot.TestDate); }
public void TesterIdWillBeNullIfNoActualAttributesExist() { // arrange var lot = new tblLot(); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0, new DateTime(2016, 1, 1), true, new EmployeeKeyReturn { EmployeeKey_Id = 123 }); var newLot = new Lot { Attributes = new[] { scan } }; // act LotSyncHelper.SetTestData(lot, newLot); // assert Assert.AreEqual(null, lot.TesterID); }
public void Returns_false_and_LotStat_will_not_have_been_set_if_all_defects_for_an_attribute_are_resolved() { var oldLot = new tblLot(); Assert.False(LotSyncHelper.SetProductSpecDefectStat(oldLot, new List <LotAttribute> { new LotAttribute { AttributeShortName = StaticAttributeNames.H2O.ShortName, AttributeValue = 1 }, }, new List <CustomerProductAttributeRange> { new CustomerProductAttributeRange { RangeMin = 2, RangeMax = 3, AttributeShortName = StaticAttributeNames.H2O.ShortName } }, new List <IAttributeDefect> { new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec, Resolution = new LotDefectResolution() } }, new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec, Resolution = new LotDefectResolution() } }, })); Assert.IsNull(oldLot.LotStat); }
public void Returns_true_and_LotStat_will_have_been_set_if_a_single_unresolved_defect_exists_for_an_attribute() { var oldLot = new tblLot(); Assert.IsTrue(LotSyncHelper.SetProductSpecDefectStat(oldLot, new List <LotAttribute> { new LotAttribute { AttributeShortName = StaticAttributeNames.H2O.ShortName, AttributeValue = 1 }, }, new List <CustomerProductAttributeRange> { new CustomerProductAttributeRange { RangeMin = 2, RangeMax = 3, AttributeShortName = StaticAttributeNames.H2O.ShortName } }, new List <IAttributeDefect> { new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec, Resolution = new LotDefectResolution() } }, new LotAttributeDefect { AttributeShortName = StaticAttributeNames.H2O.ShortName, LotDefect = new LotDefect { DefectType = DefectTypeEnum.ProductSpec } }, })); Assert.AreEqual((int)LotStat.Low_Water, oldLot.LotStat); }
public void Sets_lot_attribute_values_as_expected() { //Arrange var lot = new tblLot(); var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.AreEqual(asta.AttributeValue, lot.AvgAsta); Assert.AreEqual(scoville.AttributeValue, lot.AvgScov); Assert.AreEqual(scan.AttributeValue, lot.Scan); }
public void SetsTesterIdFromLatestAttributeEmployeeId() { // arrange var lot = new tblLot(); var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0, DateTime.MinValue); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f, new DateTime(2015, 12, 12)); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0, new DateTime(2016, 1, 1), employee: new EmployeeKeyReturn { EmployeeKey_Id = 123 }); var newLot = new Lot { Attributes = new[] { asta, scoville, scan } }; // act LotSyncHelper.SetTestData(lot, newLot); // assert Assert.AreEqual(123, lot.TesterID); }
public void SetsTestDateFromMaxDateOfAttributes() { // arrange var lot = new tblLot(); var minDate = DateTime.Now.AddDays(-5).Date; var expectedDate = DateTime.Now.Date; var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0, minDate); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f, minDate); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0, expectedDate); var newLot = new Lot { Attributes = new[] { asta, scoville, scan } }; // act LotSyncHelper.SetTestData(lot, newLot); // assert Assert.True(lot.TestDate.HasValue); Assert.AreEqual(expectedDate, lot.TestDate); }
public void Does_not_override_lot_attributes_with_computed_values() { //Arrange var lot = new tblLot { AvgAsta = 10 }; var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0, null, true); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.AreEqual(scoville.AttributeValue, lot.AvgScov); Assert.AreEqual(scan.AttributeValue, lot.Scan); Assert.AreEqual(10, lot.AvgAsta); }
public void Returns_true_and_LotStat_will_have_been_set_if_attribute_is_out_of_range_of_a_customer_spec() { var oldLot = new tblLot(); Assert.IsTrue(LotSyncHelper.SetProductSpecDefectStat(oldLot, new List <LotAttribute> { new LotAttribute { AttributeValue = 1, AttributeShortName = StaticAttributeNames.H2O.ShortName } }, new List <CustomerProductAttributeRange> { new CustomerProductAttributeRange { RangeMin = 2, RangeMax = 3, AttributeShortName = StaticAttributeNames.H2O.ShortName } }, null)); Assert.AreEqual((int)LotStat.Low_Water, oldLot.LotStat); }
private static void SetLotAttributes(ProductionBatch productionBatch, tblLot lot) { var lotAttributes = productionBatch.Production.ResultingChileLot.Lot.Attributes.ToList(); LotSyncHelper.SetLotAttributes(lot, lotAttributes); SetLotBatchAttributes(lot, lotAttributes); }