Пример #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
        public void GetServiceControllerActionCallsTheServicesUseCase()
        {
            var requestParams = Randomm.Create <GetServiceByIdRequest>();

            _classUnderTest.GetService(requestParams);
            _mockUseCase.Verify(uc => uc.ExecuteGet(It.Is <GetServiceByIdRequest>(p => p == requestParams)), Times.Once);
        }
        // Расчет стоимости после выбора услуги
        private void cbServiceName_SelectedValueChanged(object sender, EventArgs e)
        {
            if (sender is NumericUpDown && cbServiceName.SelectedItem == null)
            {
                return;
            }

            int stuffsNumber = (int)nudStuffsNumber.Value;
            int serviceCost  = ServiceController.GetService(cbServiceName.SelectedItem.ToString()).Cost;
            int resultCost   = stuffsNumber * serviceCost;

            if (cbWithDelivery.Checked)
            {
                resultCost += deliveryCost;
            }

            tbCost.Text = resultCost.ToString();
        }
Пример #4
0
        public void Test_GetService()
        {
            //Arrange
            var result = servicesController.GetService(1);

            try
            {
                //Acts
                Service service;

                //Assert
                Assert.IsTrue(result.TryGetContentValue <Service>(out service));
                Assert.AreEqual(1, service.ServiceId);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }