Exemplo n.º 1
0
        public void Validate_should_validate_authentication_model_required_fields()
        {
            var validationMessageProvider = new ValidationMessageProvider();
            IValidationService service    = new ValidationService(null, validationMessageProvider);
            var errors = service.Validate(new AuthenticationModel());

            Assert.AreEqual(2, errors.Count);
            Assert.AreSame(validationMessageProvider.Get(ValidationMessageKeys.Authentication_UserName_Required),
                           errors.First().Message);
            Assert.AreSame(validationMessageProvider.Get(ValidationMessageKeys.Authentication_Password_Required),
                           errors.Last().Message);
        }
Exemplo n.º 2
0
        public void Validate_should_validate_character_edit_model_name_unique()
        {
            var characterDao = new Mock <ICharacterDao>();

            characterDao.Setup(x => x.Load(It.IsAny <string>())).Returns(new Character()
            {
                Id = Guid.NewGuid()
            });
            var validationMessageProvider = new ValidationMessageProvider();
            IValidationService service    = new ValidationService(characterDao.Object, validationMessageProvider);
            var errors = service.Validate(new CharacterEditModel()
            {
                Name = "Zeratul"
            });

            Assert.That(errors.Any(e => e.Property == "Name" && ReferenceEquals(e.Message, validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Name_Must_Be_Unique))));
        }
Exemplo n.º 3
0
        public void Validate_should_validate_character_edit_model_name_characters()
        {
            var characterDao = new Mock <ICharacterDao>();
            var validationMessageProvider = new ValidationMessageProvider();
            IValidationService service    = new ValidationService(characterDao.Object, validationMessageProvider);
            var errors = service.Validate(new CharacterEditModel()
            {
                Name = "123!@#"
            });

            Assert.That(errors.Any(e => e.Property == "Name" && ReferenceEquals(e.Message, validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Name_Special_Characters))));
        }
Exemplo n.º 4
0
        public void Validate_should_validate_character_edit_model_required_fields()
        {
            var characterDao = new Mock <ICharacterDao>();
            var validationMessageProvider = new ValidationMessageProvider();
            IValidationService service    = new ValidationService(characterDao.Object, validationMessageProvider);
            var errors = service.Validate(new CharacterEditModel());

            Assert.That(errors.Any(e => e.Property == "Name" && ReferenceEquals(e.Message, validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Name_Required))));
            Assert.That(errors.Any(e => e.Property == "Type" && ReferenceEquals(e.Message, validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Type_Required))));
            Assert.That(errors.Any(e => e.Property == "Price" && ReferenceEquals(e.Message, validationMessageProvider.Get(ValidationMessageKeys.CharacterEdit_Price_Boundaries))));
        }