public void Validate_NullOrEmpty_ReturnFalse(string passwordHash)
        {
            // Act
            var result = _validator.Validate(passwordHash);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("NullOrEmpty", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_InvalidJweToken_ReturnFalse(string input)
        {
            // Act
            var result = _validator.Validate(input);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("NotJweToken", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_HashIsNotSHA256_ReturnFalse(string passwordHash)
        {
            // Act
            var result = _validator.Validate(passwordHash);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("NotSha256", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_FileStreamIsNull_ReturnFalse()
        {
            // Act
            var result = _validator.Validate("Test.jpg", null);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("FileStreamIsNull", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_FileNameIsNullOrEmpty_ReturnFalse()
        {
            // Act
            var result = _validator.Validate("", null);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("FileNameNullOrWhitespace", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_FileExtensionIsInvalid_ReturnFalse()
        {
            // Act
            var result = _validator.Validate("Test.tiff", null);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("FileExtensionEmptyOrInvalid", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_FileStreamIsTooShort_ReturnFalse()
        {
            // Arrange
            var stream = new MemoryStream(new byte[] { 1 });

            // Act
            var result = _validator.Validate("Test.jpg", stream);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("FileStreamIsTooShort", ValidationResultHelper.GetFirstErrorCodeName(result));
        }
        public void Validate_FileHasInvalidSignature_ReturnFalse(
            ImageTypeTestDataDto dto)
        {
            // Act
            var result = _validator.Validate(dto.File.FileName, dto.Stream);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("InvalidHexSignature", ValidationResultHelper.GetFirstErrorCodeName(result));

            // Dispose
            dto.Stream?.Dispose();
        }
Esempio n. 9
0
        public void Validate_NullOrEmpty_ReturnFalse(string input)
        {
            // Arrange
            var validator = new NoSpecialCharactersValidator();

            // Act
            var result    = validator.Validate(input);
            var errorCode = ValidationResultHelper.GetFirstErrorCodeName(result);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("NullOrEmpty", errorCode);
        }
Esempio n. 10
0
        public void Validate_InvalidStringWithAdditionalRestrictedCharacters_ReturnsFalse(string input,
                                                                                          char[] additionalRestrictedCharacters)
        {
            // Arrange
            var validator = new NoSpecialCharactersValidator(c => { c.SetRestricted(additionalRestrictedCharacters); });

            // Act
            var result    = validator.Validate(input);
            var errorCode = ValidationResultHelper.GetFirstErrorCodeName(result);

            // Assert
            Assert.False(result.IsValid);
            Assert.AreEqual("ContainsSpecialCharacters", errorCode);
        }