コード例 #1
0
        public AdminValidation(Admin model, bool PasswordNotEdited = false) //PasswordNotEdited is only true if the user typed in something in the password entry of the form.
        {                                                                   //Otherwise password remains unchanged.
            if (string.IsNullOrWhiteSpace(model.Username))
            {
                ErrorDict.Add(nameof(model.Username), ErrorCodes.IsRequired);
            }
            else if (model.Username.Length > MAX_USERNAME_LENGTH)
            {
                ErrorDict.Add(nameof(model.Username), ErrorCodes.TooLong);
            }
            if (!PasswordNotEdited)
            {
                if (string.IsNullOrWhiteSpace(model.Password))
                {
                    ErrorDict.Add(nameof(model.Password), ErrorCodes.IsRequired);
                }
                else if (!Regex.IsMatch(model.Password, PASSWORD_REQ_REGEX))
                {
                    ErrorDict.Add(nameof(model.Password), ErrorCodes.PasswordDoesNotMatch);
                }
            }

            if (ErrorDict.Count == 0)
            {
                IsValid = true;
            }
        }
        public ClassificationValidation(Classification model)
        {
            if (String.IsNullOrWhiteSpace(model.Signum))
            {
                ErrorDict.Add(nameof(model.Signum), ErrorCodes.IsRequired);
            }
            else if (model.Signum.Length > NAME_MAX_LENGTH)
            {
                ErrorDict.Add(nameof(model.Signum), ErrorCodes.MoreThanFiftyChars);
            }

            if (string.IsNullOrWhiteSpace(model.Description))
            {
                ErrorDict.Add(nameof(model.Description), ErrorCodes.IsRequired);
            }
            else if (model.Description.Length > DESCRIPTION_MAX_LENGTH)
            {
                ErrorDict.Add(nameof(model.Description), ErrorCodes.MoreThanFiveHundredChars);
            }

            if (ErrorDict.Count == 0)
            {
                IsValid = true;
            }
        }
コード例 #3
0
        public AuthorValidation(Author model)
        {
            if (!string.IsNullOrWhiteSpace(model.FirstName))
            {
                if (model.FirstName.Length > MAX_NAME_LENGTH)
                {
                    ErrorDict.Add(nameof(model.FirstName), ErrorCodes.TooLong);
                }
            }

            if (string.IsNullOrWhiteSpace(model.LastName))
            {
                ErrorDict.Add(nameof(model.LastName), ErrorCodes.IsRequired);
            }
            else if (model.LastName.Length > MAX_NAME_LENGTH)
            {
                ErrorDict.Add(nameof(model.LastName), ErrorCodes.TooLong);
            }

            if (model.BirthYear != null)
            {
                if (model.BirthYear < MIN_BIRTH_YEAR || model.BirthYear > DateTime.Now.Year - 5)
                {
                    ErrorDict.Add(nameof(model.BirthYear), ErrorCodes.InvalidRange);
                }
            }

            if (ErrorDict.Count == 0)
            {
                IsValid = true;
            }
        }
コード例 #4
0
        /// <summary>
        /// Register a single command
        /// </summary>
        /// <param name="cmdName"></param>
        /// <param name="cmd"></param>
        internal void RegisterErrorCommand(string cmdName, CommandOperand cmd)
        {
            var name = new NameOperand();

            name.Value = cmdName;
            cmd.Name   = $"build-in:{cmdName}"; // this name is for debugging purposes only
            ErrorDict.Add(name, cmd);
        }
コード例 #5
0
        public void CollapseCollectionToNonempty()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            Assert.Fail("{0}", ErrorDict.NextMsg());
            //Assert.Fail("Test method threw exception: System.AggregateException: One or more errors occurred. ---> FabrikamFiber.ServiceGateway.Core.WebApi.ObjectAlreadyExistsException: TF200019: The object already exists on the Server");
        }
コード例 #6
0
        public void CustomerHub_VerifyInlineEditParameterValuesInConflictingEdits()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #7
0
        public void TicketsHub_VerifyRunTicketOnDemandNoActiveTestsFromContextMenu()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #8
0
        public void HooksProviderQueryWithInvalidPublisherId()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #9
0
        public void CallUnregisterWithInvalidRunSettingsFile()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #10
0
        public void ProfileFrameworkInterface_SetCountrytoEmptyString()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #11
0
        public void DoNotReaddPermissionsToProjectAdminsGroup()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #12
0
        public void AccountDynamicBlade()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #13
0
        public void PSHttpClient_SetCountrytoInvalidCountry()
        {
            Random random       = new Random();
            int    randomNumber = random.Next(10, 50);

            System.Threading.Thread.Sleep(randomNumber);
            if (randomNumber > 35)
            {
                Assert.Fail("{0}", ErrorDict.NextMsg());
            }
        }
コード例 #14
0
        public BookValidation(Book model)
        {
            if (String.IsNullOrWhiteSpace(model.ISBN))
            {
                ErrorDict.Add(nameof(model.ISBN), ErrorCodes.IsRequired);
            }
            else if (!model.ISBN.All(char.IsDigit))
            {
                ErrorDict.Add(nameof(model.ISBN), ErrorCodes.MustBeOnlyNumbers);
            }
            else if (model.ISBN.Length > MAX_ISBN || model.ISBN.Length < MIN_ISBN)
            {
                ErrorDict.Add(nameof(model.ISBN), ErrorCodes.InvalidRange);
            }

            if (String.IsNullOrWhiteSpace(model.Title))
            {
                ErrorDict.Add(nameof(model.Title), ErrorCodes.IsRequired);
            }
            else if (model.Title.Length > TITLE_MAX_LENGTH)
            {
                ErrorDict.Add(nameof(model.Title), ErrorCodes.InvalidRange);
            }

            if (model.PublicationYear < MIN_PUBLICATION_YEAR || model.PublicationYear > DateTime.Now.Year)
            {
                ErrorDict.Add(nameof(model.PublicationYear), ErrorCodes.InvalidRange);
            }

            if (model.Publicationinfo != null)
            {
                if (model.Publicationinfo.Length > DESCRIPTION_MAX_LENGTH)
                {
                    ErrorDict.Add(nameof(model.Publicationinfo), ErrorCodes.InvalidRange);
                }
            }

            if (model.Pages > BOOK_MAX_LENGTH || model.Pages < 1)
            {
                ErrorDict.Add(nameof(model.Pages), ErrorCodes.InvalidRange);
            }

            if (model.Classification == null)
            {
                ErrorDict.Add(nameof(model.Classification), ErrorCodes.IsRequired);
            }

            if (ErrorDict.Count == 0)
            {
                IsValid = true;
            }
        }
コード例 #15
0
 public void BooksExistInClassification(string type)
 {
     IsValid = false;
     ErrorDict.Add(type, ErrorCodes.BooksExistInClassification);
 }