public void AddLineItemAlternateCreatedByMaintenanceTeamAccidentallySixMonthsLater(LineItem lineItem) { lineItem.Parent = this; LineItem nullChecker = null; _lineItems.TryGetValue(lineItem.InvoiceNumber, out nullChecker); if(nullChecker == null) _lineItems.Add(lineItem.InvoiceNumber, lineItem); }
public void AddLineItem(LineItem lineItem) { lineItem.Parent = this; LineItem nullChecker = null; _lineItems.TryGetValue(lineItem.Id, out nullChecker); if(nullChecker == null) _lineItems.Add(lineItem.Id, lineItem); }
public void Junior_Dev_Accidentally_Changes_Identity_And_Equality_In_Second_Method() { var lineItem1 = new LineItem { Id = 35, Description = "Shirt", InvoiceNumber=10001 }; var lineItem2 = new LineItem { Id = 35, Description = "Shirt", InvoiceNumber=10002 }; var sut = new Invoice { Id = 1 }; Assert.AreEqual(0, sut.LineItems().Count()); sut.AddLineItemAlternateCreatedByMaintenanceTeamAccidentallySixMonthsLater(lineItem1); sut.AddLineItemAlternateCreatedByMaintenanceTeamAccidentallySixMonthsLater(lineItem2); Assert.AreEqual(1, sut.LineItems().Count(), "LineItems should only increment for unique Id"); }
public void AddLineItem_Checks_Identity_and_Equality_Based_On_Id_Property() { var lineItem1 = new LineItem { Id = 35, Description = "Shirt" }; var lineItem2 = new LineItem { Id = 35, Description = "Shirt" }; var sut = new Invoice { Id = 1 }; Assert.AreEqual(0, sut.LineItems().Count()); sut.AddLineItem(lineItem1); sut.AddLineItem(lineItem2); Assert.AreEqual(1, sut.LineItems().Count(), "LineItems should only increment for unique Id"); }