Beispiel #1
0
 private void btnDeleteShipper_Click(object sender, EventArgs e)
 {
     try
     {
         int temp;
         if (int.TryParse(tboShipperID.Text, out temp))
         {
             var data = new Shipper() { ShipperID = temp };
             var mgr = new NorthwindManager();
             mgr.DeleteShipper(data);
             //feedback to user
             PopulateShippersComboBox();
             //clear the form textboxes
             tboShipperID.Text = "";
             tboCompanyName.Text = "";
             tboPhone.Text = "";
         }
         else
         {
             MessageBox.Show("Please lookup a shipper before trying to delete.");
         }
     }
     catch (Exception ex)
     {
         //TODO: Log the exception
         Program.LogMessage(ex.Message);
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
        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);
        }