public void BadUseOfTernarOperator()
        {
            var analyzer = new PropertyPathAnalyzer();
            var resolver = new XamlTypeResolverMock(null);

            var badPathes = new [] {
                "(Color>local:Colors.Enum?Color:Color",
                "(Color>local:Colors.Enum?Color: Color",
                "(Color>local:Colors.Enum?Color :Color",
                "(Color>local:Colors.Enum?local:Color.prop: Color",
                "(Color>local:Colors.Enum?local:Color.prop :Color",
            };

            foreach (var path in badPathes)
            {
                try
                {
                    analyzer.GetPathes(path, null);
                }
                catch (Exception e)
                {
                    continue;
                }
                Assert.Fail("Exception must be thrown! Path = {0}", path);
            }
        }
        private void AssertPropertyPathes(string path, IXamlTypeResolver typeResolver, bool positionsCheck, params PathToken[] expectedTokens)
        {
            var analyzer = new PropertyPathAnalyzer();

            var tokens = analyzer.GetPathes(path, typeResolver);

            CollectionAssert.AreEqual(expectedTokens.ToList(), tokens, new TestPathComparer(positionsCheck));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Find all sourceProperties pathes in Path string
        /// </summary>
        /// <param name="normPath"></param>
        /// <returns>List of pathes and its start positions</returns>
        private List <PathAppearances> GetSourcePathes(string normPath, IXamlTypeResolver typeResolver)
        {
            var propertyPathAnalyzer = new PropertyPathAnalyzer();

            var pathes = propertyPathAnalyzer.GetPathes(normPath, typeResolver);

            var propertiesGroups = pathes.GroupBy(p => p.Id).Select(p => new PathAppearances(p.Key, p.ToList())).ToList();

            return(propertiesGroups);
        }