Пример #1
0
        public async Task CreateAddressExceptionCatch()
        {
            // Arrange

            mockRepo.Setup(x => x.Address).Returns(_addressRepoMock.Object);
            _addressRepoMock.Setup(x => x.CreateAddress(new Address())).Throws(new Exception());

            // Act
            var result = await _sut.CreateAddress(new AddressForCreationDto());

            // Assert
            mockLogger.Verify(x => x.LogError("Something went wrong inside CreateAddress(addressDto) action: Object reference not set to an instance of an object."), Times.Once);
            Assert.IsType <ObjectResult>(result);
        }
        private void SubmitChange_Click(object sender, RoutedEventArgs e)
        {
            string city    = ChangeCurrentCity.Text;
            string address = ChangeAddress.Text;

            string[] parts  = city.Split(", ");
            string[] parts2 = address.Split(", ");
            City     c      = new City(parts[0], new State(parts[1]));

            try
            {
                if (!cityController.CheckIfExists(c))
                {
                    cityController.CreateCity(c);
                }
                else
                {
                    c = cityController.GetCityByName(c);
                }

                Address a = new Address(parts2[0], int.Parse(parts2[1]), 0, 0, c);
                if (addressController.CheckIfExists(a))
                {
                    a = addressController.GetExistentAddress(a);
                }
                else
                {
                    a = addressController.CreateAddress(a);
                }


                var dr = MainWindow.doctor;
                validate.IsEmailValid(ChangeEmail.Text);
                dr.Email         = ChangeEmail.Text;
                dr.Phone         = ChangePhoneNumber.Text;
                dr.CurrResidence = a;
                userController.UpdateUserProfile(dr);
                MainWindow.doctor = (Doctor)userController.GetUser(MainWindow.doctor.Username);

                NavigationService.Navigate(new Uri("/Pages/ProfileAndNotification/Profile.xaml", UriKind.Relative));

                NavigationService.Navigate(new Uri("/Pages/ProfileAndNotification/Profile.xaml", UriKind.Relative));
            } catch (IncorrectEmailAddress)
            {
                Napomena.Visibility     = Visibility.Collapsed;
                Error.Text              = "Nevalidan format email adrese!";
                ErrorMessage.Visibility = Visibility.Visible;
            } catch (Exception)
            {
                Napomena.Visibility     = Visibility.Collapsed;
                Error.Text              = "Došlo je do neke greške!";
                ErrorMessage.Visibility = Visibility.Visible;
            }
        }
Пример #3
0
        private void CreateOrder()
        {
            var items = _basketController.GetBasketItems();

            if (items.Any())
            {
                BaseConsoleFunction.WithdrawList(items.ToArray());
                if (BaseConsoleFunction.CheckArea("Want to issue a order ? y/n", "y"))
                {
                    var phoneNumber = Checker.GetPropertyPhoneNumber(BaseConsoleFunction.GetProperty("Enter phone"));
                    var street      = Checker.GetPropertyStreet(BaseConsoleFunction.GetProperty("Enter street"));
                    var houseNumber = Checker.GetPropertyHome(BaseConsoleFunction.GetProperty("Enter house number"));
                    var address     = AddressController.CreateAddress(street, houseNumber);
                    _clientController.CreateOrder(phoneNumber, address, _basketController.Basket);
                    _basketController.ClearBasket();
                    Console.WriteLine("Order was created!");
                    Console.ReadLine();
                }
            }
            else
            {
                BaseConsoleFunction.GetProperty("Your basket is empty. Press enter to continue ");
            }
        }