Exemplo n.º 1
0
        public static PropertyNT_ Create(string propertyLine)
        {
            var result = new PropertyNT_(); // {Name = name, Value = value};

            // Execute static method to populate result parameters
            PropertyNT_Methods.Property_Parse(propertyLine, out result.Scope, out result.Type, out result.Name, out result.Type_Part1, out result.Type_Part2, out result.Type_Part3);

            return(result);
        }
Exemplo n.º 2
0
        public static void Property_Parse_Test()
        {
            string propertyLine, scope, name, type, typePart1, typePart2, typePart3;

            #region Test1: public Types_DateTime DateTime
            //      ===========================================
            propertyLine = "public Types_DateTime DateTime";
            PropertyNT_Methods.Property_Parse(propertyLine, out scope, out type, out name, out typePart1, out typePart2, out typePart3);
            Assert.Equal("public", scope);
            Assert.Equal("Types_DateTime", type);
            Assert.Equal("DateTime", name);
            Assert.Equal("Types", typePart1);
            Assert.Equal("DateTime", typePart2);
            Assert.Equal("", typePart3);
            #endregion

            #region Test2: public Rules_ Rules
            // ===========================================
            propertyLine = "public Rules_ Rules";
            PropertyNT_Methods.Property_Parse(propertyLine, out scope, out type, out name, out typePart1, out typePart2, out typePart3);
            Assert.Equal("public", scope);
            Assert.Equal("Rules_", type);
            Assert.Equal("Rules", name);
            Assert.Equal("Rules", typePart1);
            Assert.Equal("", typePart2);
            Assert.Equal("", typePart3);
            #endregion

            #region Test3: public Types_DateTime DateTime
            //      ===========================================
            propertyLine = "public Types_DateTime_123 DateTime";
            PropertyNT_Methods.Property_Parse(propertyLine, out scope, out type, out name, out typePart1, out typePart2, out typePart3);
            Assert.Equal("Types", typePart1);
            Assert.Equal("DateTime_123", typePart2);
            Assert.Equal("123", typePart3);
            #endregion

            #region Test4: error conditions
            propertyLine = "public Types_DateTime DateTime invalidcode";
            Assert.Throws <InvalidOperationException>(() => PropertyNT_Methods.Property_Parse(propertyLine, out scope, out type, out name, out typePart1, out typePart2, out typePart3));
            #endregion
        }