コード例 #1
0
        public void Infer_SuccessfullyAccountsForReservedNames()
        {
            var config = new ProjectNameValidationConfig()
            {
                ReservedNames = new string[]
                {
                    "Prism",
                    "CaliburnMicro",
                    "MVVMLight",
                },
            };

            var validationService = new ProjectNameService(config, null);
            var result            = validationService.Infer("Prism");

            Assert.Equal("Prism1", result);
        }
コード例 #2
0
        public void Infer_SuccessfullyAccountsForExistingNames()
        {
            var existingNames = new List <string>()
            {
                "App"
            };

            Func <IEnumerable <string> > getExistingNames = () => { return(existingNames); };

            var config = new ProjectNameValidationConfig()
            {
                ValidateExistingNames = true,
            };

            var validationService = new ProjectNameService(config, getExistingNames);
            var result            = validationService.Infer("App");

            Assert.Equal("App1", result);
        }
コード例 #3
0
        public void Validate_SuccessfullyAccountsForRegex()
        {
            var config = new ProjectNameValidationConfig()
            {
                Regexs = new RegExConfig[]
                {
                    new RegExConfig()
                    {
                        Name    = "projectStartWith$",
                        Pattern = "^[^\\$]",
                    },
                },
            };

            var validationService = new ProjectNameService(config, null);
            var result            = validationService.Validate("$App");

            Assert.False(result.IsValid);
            Assert.Contains(result.Errors, e => e.ErrorType == ValidationErrorType.Regex);
            Assert.Contains(result.Errors, e => e.ValidatorName == "projectStartWith$");
        }