Ejemplo n.º 1
0
        private bool ValidateCpr(string cpr)
        {
            //return true;
            var errTitle = "Login fejl";

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetTitle(errTitle);

            builder.SetCancelable(false);
            builder.SetPositiveButton("OK", delegate { });

            // If textfield are not empty
            if (cpr != "")
            {
                CprValidator.CprError cprError;

                CprValidator.CheckCPR(cpr, out cprError);

                switch (cprError)
                {
                case CprValidator.CprError.NoError:
                    return(true);

                case CprValidator.CprError.FormatError:
                    builder.SetMessage("Forkert CPR format");
                    builder.Show();

                    return(false);

                case CprValidator.CprError.DateError:
                    builder.SetMessage("Dato i CPR er ugyldig");
                    builder.Show();

                    return(false);

                case CprValidator.CprError.Check11Error:
                    builder.SetMessage("CPR er ugyldigt");
                    builder.Show();

                    return(false);

                default:
                    builder.SetMessage("Ukendt fejl");
                    builder.Show();

                    return(false);
                }
            }

            builder.SetMessage("Indtast venligst et CPR nr");
            builder.Show();

            return(false);
        }
Ejemplo n.º 2
0
        public void CheckCPRValid_CheckingCPRIsValid_CPRIsValid()
        {
            // Arrange
            const string cpr = "0105921853";

            CprValidator.CprError cprError;

            CprValidator.CheckCPR(cpr, out cprError);

            // Act
            bool isValid = cprError == CprValidator.CprError.NoError;

            // Assert
            Assert.AreEqual(isValid, true);
        }
Ejemplo n.º 3
0
        private bool ValidateCpr(string cpr)
        {
            //return true;
            var errTitle = "Login fejl";

            // If textfield are not empty
            if (cpr != "")
            {
                CprValidator.CprError cprError;

                CprValidator.CheckCPR(cpr, out cprError);

                switch (cprError)
                {
                case CprValidator.CprError.NoError:
                    return(true);

                case CprValidator.CprError.FormatError:
                    new UIAlertView(errTitle, "Forkert CPR format", null, null, "OK").Show();
                    return(false);

                case CprValidator.CprError.DateError:
                    new UIAlertView(errTitle, "Dato i CPR er ugyldig", null, null, "OK").Show();
                    return(false);

                case CprValidator.CprError.Check11Error:
                    new UIAlertView(errTitle, "CPR er ugyldigt", null, null, "OK").Show();
                    return(false);

                default:
                    new UIAlertView(errTitle, "Ukendt fejl", null, null, "OK");
                    return(false);
                }
            }

            new UIAlertView(errTitle, "Indtast venligst et CPR nr", null, null, "OK").Show();

            return(false);
        }