示例#1
0
        public bool ValidateWork()
        {
            string error = WorkValidator.ValidateWork(NameOfCustomerTextBox.Text, CarLicensePlateTextBox.Text, TypeOfCarTextBox.Text, DetailOfIssues.Text);

            switch (error)
            {
            case "EMPTY_NAMEOFCUSTOMER":
                MessageBox.Show("A vásárló neve nem lehet üres!");
                return(false);

            case "EMPTY_CARLICENSEPLATE":
                MessageBox.Show("Az autó rendszáma nem lehet üres!");
                return(false);

            case "EMPTY_TYPEOFCAR":
                MessageBox.Show("Az autó típusa nem lehet üres!");
                return(false);

            case "TOO_SHORT_DETAILOFISSUES":
                MessageBox.Show("Az hiba leírásának legalább 3 karakternek kell lennie");
                return(false);

            default:
                return(true);
            }
        }
        public void ValidateWork_WithValidData()
        {
            string result = WorkValidator.ValidateWork("Béla", "ABC-1232", "Fiat", "brake problems");

            Assert.AreEqual("", result, "Detail of issues validation not works correctly.");
        }
        public void ValidateWork_WithInvalidDetailOfIssues()
        {
            string result = WorkValidator.ValidateWork("Béla", "ABC-1232", "Fiat", "ab");

            Assert.AreEqual("TOO_SHORT_DETAILOFISSUES", result, "Detail of issues validation not works correctly.");
        }
        public void ValidateWork_WithInvalidTypeOfCar()
        {
            string result = WorkValidator.ValidateWork("Béla", "ABC-1232", "", "");

            Assert.AreEqual("EMPTY_TYPEOFCAR", result, "Car type validation not works correctly.");
        }
        public void ValidateWork_WithInvalidCarLicensePlate()
        {
            string result = WorkValidator.ValidateWork("Béla", "", "", "");

            Assert.AreEqual("EMPTY_CARLICENSEPLATE", result, "Car license plate validation not works correctly.");
        }
        public void ValidateWork_WithInvalidNameOfCustomer()
        {
            string result = WorkValidator.ValidateWork("", "", "", "");

            Assert.AreEqual("EMPTY_NAMEOFCUSTOMER", result, "Customer name validation not works correctly.");
        }