示例#1
0
        public void CheckIfEditServiceWorks()
        {
            // Arrange
            var servicesController = new ServicesController()
            {
                Request = new HttpRequestMessage
                {
                    RequestUri = new Uri("http://localhost:44382/api/services")
                },
                Configuration = new HttpConfiguration()
            };

            try
            {
                // Act
                var     result = servicesController.GetService(1);
                Service service;
                result.TryGetContentValue <Service>(out service);
                string noneupdatedtitle = service.Title;
                service.Title = "Test";
                var     response  = servicesController.EditService(service);
                var     newresult = servicesController.GetService(1);
                Service actual;

                newresult.TryGetContentValue <Service>(out actual);

                // Assert
                Assert.IsTrue(response.IsSuccessStatusCode);
                Assert.AreNotEqual(actual.Title, noneupdatedtitle);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
示例#2
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            String malefemale = "";

            if (rb_female.Checked)
            {
                malefemale = "Female";
            }
            else
            {
                malefemale = "Male";
            }
            Service s = new Service(selectedService.ServiceId, textBox1.Text, textBox2.Text, int.Parse(textBox3.Text), decimal.Parse(textBox4.Text), malefemale);

            sc.EditService(s);
            ReloadForm();
        }