private void btnAddShipper_Click(object sender, EventArgs e) { try { Shipper item = new Shipper() { CompanyName = tboCompanyName.Text, Phone = tboPhone.Text }; var mgr = new NorthwindManager(); item.ShipperID = mgr.AddShipper(item); //Give some feedback to the user... // - Update my combo-box PopulateShippersComboBox(); // - My combo-box has the right shipper selected cboShippers.SelectedValue = item.ShipperID; // - Display the id fo the addd shipper tboShipperID.Text = item.ShipperID.ToString(); } catch (Exception ex) { //TODO: Log the exception MessageBox.Show(ex.Message); } }
public void Should_Add_Shipper() { //Arrange var sut = new NorthwindManager(); //sut is short for 'Scenario Under Test' var expected = new Shipper() { CompanyName = "Montgomery Scott's Transporter Service", Phone = "780.555.1212" }; //Act var actualId = sut.AddShipper(expected); //Assert Assert.True(actualId > 0); Shipper actual = sut.GetShipper(actualId); Assert.Equal(expected.CompanyName, actual.CompanyName); Assert.Equal(expected.Phone, actual.Phone); Assert.Equal(actualId, actual.ShipperID); }
public void Should_Delete_Shipper() { //Arrange var sut = new NorthwindManager(); //sut is short for 'Scenario Under Test' var expected = new Shipper() { CompanyName = "Montgomery Scott's Transporter Service", Phone = "780.555.1212" }; expected.ShipperID = sut.AddShipper(expected); //Act sut.DeleteShipper(expected); //Assert Shipper actual = sut.GetShipper(expected.ShipperID); Assert.Null(actual); }