Пример #1
0
        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);
        }
Пример #2
0
        public void Should_Delete_Product()
        {
            //Arrange
            var sut = new NorthwindManager();  //sut is short for 'Scenario Under Test'
            var expected = new Product()
            {
                ProductName = "Double Double",
                UnitsInStock = 777
            };

            expected.ProductID = sut.AddProduct(expected);

            //Act
            sut.DeleteProduct(expected);

            //Assert
            Shipper actual = sut.GetShipper(expected.ProductID);
            Assert.Null(actual);
        }
Пример #3
0
        private void btnLookupShipper_Click(object sender, EventArgs e)
        {
            try
            {
                //Get data from form
                if (cboShippers.SelectedIndex <= 0)
                {
                    MessageBox.Show("Please select a shipper.");
                }
                else
                {
                    int shipperId = Convert.ToInt32(cboShippers.SelectedValue);

                    NorthwindManager mgr = new NorthwindManager();
                    Shipper data = mgr.GetShipper(shipperId);

                    //Unpack the data
                    tboShipperID.Text = data.ShipperID.ToString();
                    tboCompanyName.Text = data.CompanyName;
                    tboPhone.Text = data.Phone;
                }
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show("Error: " + ex.Message, "Error Loading Form", MessageBoxButtons.OK);
            }
        }
Пример #4
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);
        }
Пример #5
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);
        }