예제 #1
0
    public void Controls_CanParseControlPath(string path, params string[] parts)
    {
        var parsed = InputControlPath.Parse(path).ToArray();

        Assert.That(parsed, Has.Length.EqualTo(parts.Length));
        Assert.That(parsed.Zip(parts, (a, b) =>
        {
            var properties = b.Split(',');
            return(properties.All(p =>
            {
                var nameAndValue = p.Split(':').ToArray();
                switch (nameAndValue[0])
                {
                case "layout": return a.layout == nameAndValue[1];

                case "usage": return a.usages.Count() == 1 && a.usages.First() == nameAndValue[1];

                case "name": return a.name == nameAndValue[1];

                case "displayName": return a.displayName == nameAndValue[1];

                case "wildcard": return a.isWildcard;
                }
                return false;
            }));
        }), Has.All.True);
    }