Exemple #1
0
 protected override void ValidateValues()
 {
     if (_canMoveByClick && _movementMouseComponent is null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_movementMouseComponent), this.gameObject.name));
     }
     if (_canInteract && _interactableComponent is null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_interactableComponent), this.gameObject.name));
     }
     if (_canPoop && _stomachComponent is null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_stomachComponent), this.gameObject.name));
     }
 }
        public void ValidateIntBadResolution(int value, int min, int max, int resolution, bool exclusiveRange, bool shouldThrow, string message)
        {
            Action action = () => ValidatorUtils.ValidateScalar(value, min, max, resolution, exclusiveRange);

            if (!shouldThrow)
            {
                action();
            }
            else
            {
                Assert.Equal(
                    string.Format(SR.GetResourceString(message, null), resolution),
                    AssertExtensions.Throws <ArgumentException>(null, action).Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// When user clicks on save secret
        /// </summary>
        /// <param name="sender">System.Windows.Forms.Button</param>
        /// <param name="e">System.Windows.Forms.MouseEventArgs</param>
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            if (ValidatorUtils.IsValidToAddNew(NameTextBox.Text, PasswordTextBox.Text, ConfirmPassTextBox.Text, ref connection) &&
                connection.AddNewSecretPassword(authentifiedUser.Id, NameTextBox.Text, PasswordTextBox.Text))
            {
                MessageBox.Show("Secret ajouté avec succés.", "Secret ajouté", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NameTextBox.Text = "";
            }
            else
            {
                MessageBox.Show("Impossible d'ajouter le secret.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            PasswordTextBox.Text    = "";
            ConfirmPassTextBox.Text = "";
        }
Exemple #4
0
        public override void Validate(object value)
        {
            if (value == null)
            {
                return;
            }

            // Make a check here since value.GetType() returns RuntimeType rather then Type
            if (!(value is Type))
            {
                ValidatorUtils.HelperParamValidation(value, typeof(Type));
            }

            if (!_base.IsAssignableFrom((Type)value))
            {
                throw new ArgumentException(SR.Format(SR.Subclass_validator_error, ((Type)value).FullName,
                                                      _base.FullName));
            }
        }
Exemple #5
0
 protected override void ValidateValues()
 {
     if (_inputManager == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_inputManager), this.gameObject.name));
     }
     if (_playerState == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_playerState), this.gameObject.name));
     }
     if (_animator == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_animator), this.gameObject.name));
     }
     if (_txtItemName == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_txtItemName), this.gameObject.name));
     }
 }
Exemple #6
0
        protected void ValidateInfo()
        {
            Messages = new List <string>();
            if (string.IsNullOrEmpty(Name) || Name.Length < 4)
            {
                Messages.Add("Name cannot be empty.");
            }
            if (string.IsNullOrEmpty(Address) || Address.Length < 4)
            {
                Messages.Add("Address must have at least 4 characters.");
            }
            if (string.IsNullOrEmpty(Phone))
            {
                Messages.Add("Phone cannot be empty.");
            }
            else if (ValidatorUtils.IsValidPhone(Phone))
            {
                Messages.Add("Phone in incorrect format.");
            }

            if (SendToDifferentAddress)
            {
                if (string.IsNullOrEmpty(AlternateName) || AlternateName.Length < 4)
                {
                    Messages.Add("Alternative name cannot be empty.");
                }
                if (string.IsNullOrEmpty(AlternateAddress) || AlternateAddress.Length < 4)
                {
                    Messages.Add("Alternative address must have at least 4 characters.");
                }
                if (string.IsNullOrEmpty(AlternatePhone))
                {
                    Messages.Add("Alternative phone number cannot be empty.");
                }
                else if (ValidatorUtils.IsValidPhone(AlternatePhone))
                {
                    Messages.Add("Phone number in incorrect format.");
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// When admin clicks on add button
 /// </summary>
 /// <param name="sender">System.Windows.Forms.Button</param>
 /// <param name="e">System.Windows.Forms.MouseEventArgs</param>
 private void AddBtn_Click(object sender, EventArgs e)
 {
     if (ValidatorUtils.IsValidToAddNew(NameTextBox.Text, PasswordTextBox.Text, ConfirmPassTextBox.Text, ref connection) &&
         connection.InsertNewUser(NameTextBox.Text, PasswordTextBox.Text) == 1 &&
         connection.InsertNewImage(NameTextBox.Text, PasswordTextBox.Text) == 1 &&
         connection.InsertNewLog(NameTextBox.Text, PasswordTextBox.Text) == 1)
     {
         MessageBox.Show("L'utilisateur correctement ajouté.",
                         "Utilisateur créé",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Impossible de créer l'utilisateur.\n"
                         + "Le nom doit être unique, le nom et le mot de passe "
                         + "doivent contenir plus de "
                         + Properties.Settings.Default.AuthMinSize,
                         "Erreur",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
 protected override void ValidateValues()
 {
     if (_animator == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_animator), this.gameObject.name));
     }
     if (_inputManager == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_inputManager), this.gameObject.name));
     }
     if (_playerState == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_playerState), this.gameObject.name));
     }
     if (_plantComponent == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_plantComponent), this.gameObject.name));
     }
     if (_internalCanvas == null)
     {
         Debug.LogError(ValidatorUtils.ValidateNullAtGameObject(nameof(_internalCanvas), this.gameObject.name));
     }
 }
        public void GetObjectMarshallTest()
        {
            var operation = service_model.FindOperation("GetObject");

            var request    = InstantiateClassGenerator.Execute <GetObjectRequest>();
            var marshaller = new GetObjectRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);

            TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model);

            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "Cache-Control",    "Cache-Control_Value"                                },
                    { "Content-Length",   long.MaxValue.ToString(CultureInfo.InvariantCulture) },
                    { "Content-Range",    "Content-Range_Value"                                },
                    { "Content-Type",     "Content-Type_Value"                                 },
                    { "ETag",             "ETag_Value"                                         },
                    { "Last-Modified",    ValidatorUtils.GetTestDate(TimestampFormat.RFC822)   },
                    { "x-amzn-RequestId", Guid.NewGuid().ToString()                            },
                    { "x-amz-crc32",      "0"                                                  }
                }
            };

            var payloadResponse = new JsonSampleGenerator(service_model, operation.ResponseStructure).Execute();

            webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString();
            var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse);
            ResponseUnmarshaller unmarshaller = GetObjectResponseUnmarshaller.Instance;
            var response = unmarshaller.Unmarshall(context)
                           as GetObjectResponse;

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
        public void IsValidToUpdatePasswordTestGood()
        {
            bool isValid = ValidatorUtils.IsValidToUpdatePassword("123456", "123456");

            Assert.IsTrue(isValid);
        }
Exemple #11
0
 public void Test1()
 {
     ValidatorUtils.isCpf("058.826.359-18");
 }
Exemple #12
0
 protected bool IsValid()
 {
     return(!string.IsNullOrWhiteSpace(Username) && !string.IsNullOrWhiteSpace(Password) && !string.IsNullOrWhiteSpace(Email) && ValidatorUtils.IsValidEmail(Email) &&
            !DuplicateEmail && !DuplicateUsername);
 }
 public Task<bool> ValidateLoginAndPasswordAsync(string login, string password)
 {
     return ValidatorUtils.IsValidEmail(login) ? ValidateEmailAndPasswordAsync(login, password) : ValidateUsernameAndPasswordAsync(login, password);
 }
        public void IsValidToUpdatePasswordTestWithShortPassword()
        {
            bool isValid = ValidatorUtils.IsValidToUpdatePassword("123", "123");

            Assert.IsFalse(isValid);
        }
 public void IsCpf_should_returnTrue(string value)
 {
     Assert.True(ValidatorUtils.IsCpf(value));
 }
        public void IsValidToUpdatePasswordTestNotSame()
        {
            bool isValid = ValidatorUtils.IsValidToUpdatePassword("12345678910", "123456");

            Assert.IsFalse(isValid);
        }
 public void IsCpf_should_returnFalse_because_invalidCpf(string value)
 {
     Assert.False(ValidatorUtils.IsCpf(value));
 }
        public void IsValidToUpdateUserTestWithNegativeId()
        {
            bool isValid = ValidatorUtils.IsValidToUpdateUser("-4");

            Assert.IsFalse(isValid);
        }
        public void IsValidToUpdateUserTestWithCharId()
        {
            bool isValid = ValidatorUtils.IsValidToUpdateUser("a");

            Assert.IsFalse(isValid);
        }
        public void IsValidToUpdateUserTestWithValidId()
        {
            bool isValid = ValidatorUtils.IsValidToUpdateUser("1");

            Assert.IsTrue(isValid);
        }