SchemaZen.Library.Models.Routine.Warnings C# (CSharp) Method

Warnings() public method

public Warnings ( ) : IEnumerable
return IEnumerable
        public IEnumerable<string> Warnings()
        {
            if (string.IsNullOrEmpty(Text)) {
                yield return "Script definition could not be retrieved.";
            } else {
                // check if the name is correct
                var regex = new Regex(string.Format(SqlCreateWithNameRegex, GetSQLTypeForRegEx()),
                    RegexOptions.IgnoreCase | RegexOptions.Singleline);
                var match = regex.Match(Text);

                // the schema is captured in group index 2, and the name in 3

                var nameGroup = match.Groups[3];
                if (nameGroup.Success) {
                    var name = nameGroup.Value;
                    if (name.StartsWith("[") && name.EndsWith("]"))
                        name = name.Substring(1, name.Length - 2);

                    if (string.Compare(Name, name, StringComparison.InvariantCultureIgnoreCase) != 0) {
                        yield return string.Format("Name from script definition '{0}' does not match expected name '{1}'", name, Name);
                    }
                }
            }
        }

Usage Example

Esempio n. 1
0
		public void TestScriptWarnings() {
			var f = new Routine("dbo", "udf_GetDate2", null) {
				Text = ExampleFunc,
				RoutineType = Routine.RoutineKind.Function
			};
			Assert.IsTrue(f.Warnings().Any());
		}
All Usage Examples Of SchemaZen.Library.Models.Routine::Warnings