public void CheckAdress_WhenUserDataIsInvalid_ShouldReturnErrorWithMessage(string adress)
        {
            //Arrange
            (bool, string)expected = (false, UserMessages.InvalidAddressFormat);

            //Act
            var result = DataValidationManager.CheckAddress(adress);

            //Assert
            Assert.Equal(expected, result);
        }
        public void CheckAdress_WhenUserDataIsCorrect_ShouldReturnCorrectResult()
        {
            //Arrange
            (bool, string)expected = (true, string.Empty);
            string adress = "Koktajlowo 16";

            //Act
            var result = DataValidationManager.CheckAddress(adress);

            //Assert
            Assert.Equal(expected, result);
        }
Exemple #3
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            List <(bool, string)> validators = new List <(bool, string)>()
            {
                DataValidationManager.CheckEmail(EmailTextBox.Text),
                DataValidationManager.CheckFirstName(FirstNameTextBox.Text),
                DataValidationManager.CheckLastName(LastNameTextBox.Text),
                DataValidationManager.CheckAddress(AddressTextBox.Text),
            };

            foreach (var validator in validators)
            {
                if (!string.IsNullOrEmpty(validator.Item2))
                {
                    MessageBox.Show(validator.Item2, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
            }

            if (validators.TrueForAll(x => x.Item1))
            {
                var emailBody = string.Format(emailBodyFormat, AddressTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, NotesTextBox.Text);

                EmailSendStatus emailSendStatus = new EmailManager().SendEmail(EmailTextBox.Text, "Pizza Application Order", emailBody);

                if (emailSendStatus.SendSuccessfully)
                {
                    MessageBox.Show(UserMessages.EmailSended, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    AddHistoryRecordToDatabase();
                    UserActionHelpers.ClearAllTextBoxData();
                    Hide();
                    WindowsManagement.GetMainWindowInstance().Show();
                }
                else
                {
                    MessageBox.Show(UserMessages.EmailFailedToSend, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }