Пример #1
0
        public void ValidateVersionPattern_NoErrors(string pattern)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = pattern
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Пример #2
0
        public void ValidateVersionPattern_Errors_PatternTooLong(string pattern)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = pattern
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Pattern contains too many parts.", errors[0]);
        }
Пример #3
0
        public void ValidateVersionPattern_Errors_EmptyPattern(string pattern)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = pattern
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Pattern cannot be empty.", errors[0]);
        }
Пример #4
0
        public void ValidateVersionPattern_Errors_InvalidSpecialKeywords()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = "{REVISION}.{BUILD}.{MINOR}.{MAJOR}"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(4, errors.Count);
            Assert.AreEqual("Invalid special keyword for major number.", errors[0]);
            Assert.AreEqual("Invalid special keyword for minor number.", errors[1]);
            Assert.AreEqual("Invalid special keyword for build number.", errors[2]);
            Assert.AreEqual("Invalid special keyword for revision number.", errors[3]);
        }
Пример #5
0
        public void ValidateVersionPattern_Errors_NegativeNumbers()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = "-1.-1.-1.-1"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(4, errors.Count);
            Assert.AreEqual("Major number cannot be negative.", errors[0]);
            Assert.AreEqual("Minor number cannot be negative.", errors[1]);
            Assert.AreEqual("Build number cannot be negative.", errors[2]);
            Assert.AreEqual("Revision number cannot be negative.", errors[3]);
        }
Пример #6
0
 public void ValidateVersionPattern_ArgumentNullException_Model()
 {
     // Act & Assert
     // ReSharper disable once AssignNullToNotNullAttribute
     Assert.Throws <ArgumentNullException>(() => ConfigurationModelValidations.ValidateVersionPattern(null));
 }