Example #1
0
        private void btnUpdateShipper_Click(object sender, EventArgs e)
        {
            try
            {
                int shipperId;
                if (int.TryParse(tboShipperID.Text, out shipperId))
                {
                    //Do the update
                    var info = new Shipper()
                    {
                        ShipperID = shipperId,
                        CompanyName = tboCompanyName.Text,
                        Phone = tboPhone.Text
                    };

                    var mgr = new NorthwindManager();
                    mgr.UpdateShipper(info);
                    PopulateShippersComboBox();
                    cboShippers.SelectedValue = info.ShipperID;
                }

                else
                {
                    MessageBox.Show("Please lookup a shipper before trying to update.");
                }
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        public void Should_Update_Shipper(Shipper existing)
        {
            //Arrange
            existing.Phone = "780.999.999";
            var sut = new NorthwindManager();  //sut is short for 'Scenario Under Test'
            existing.Phone = "780.555.1212";

            //Act
            sut.UpdateShipper(existing);

            //Assert
            var actual = sut.GetShipper(existing.ShipperID);
            Assert.NotNull(actual);
            Assert.Equal(existing.CompanyName, actual.CompanyName);
            Assert.Equal(existing.Phone, actual.Phone);
        }