Ejemplo n.º 1
0
 public void IsValid_Success(
     PageRule pageRule,
     bool expectedResult)
 {
     // Arrange & Act & Assert
     Assert.Equal(expectedResult, pageRule?.IsValid);
 }
        public void Page_Success()
        {
            // Arrange
            var page = new PageRule();

            // Act
            _queryParameters.Page = page;

            // Assert
            Assert.Equal(page, _queryParameters.Page);
        }
Ejemplo n.º 3
0
        static RuleConfig()
        {
            using (JsonReader jsonReader = new JsonTextReader(new StreamReader("rule.json")))
            {
                JObject jObject = JObject.Load(jsonReader);

                var jTokens = jObject["Rule"]?.AsJEnumerable();

                if (jTokens != null)
                {
                    var _pageRule = new PageRule();

                    foreach (var jToken in jTokens)
                    {
                        PageType pageType;

                        if (!Enum.TryParse(jToken?.Value <string>("PageType"), out pageType))
                        {
                            continue;
                        }

                        Page page = new Page();

                        var jRules = jToken["Rules"].AsJEnumerable();

                        foreach (var jRule in jRules)
                        {
                            Rule.Rule rule = new Rule.Rule()
                            {
                                Name  = jRule?.Value <string>("Name"),
                                XPath = jRule?.Value <string>("XPath"),
                                Fun   = Enum.Parse <Rule.Rule.RuleFun>(jRule?.Value <string>("Fun")),
                                Param = jRule?.Value <string>("Param"),
                            };
                            page.Add(rule);
                        }

                        _pageRule.AddRule(pageType, page);
                    }

                    pageRule = _pageRule;
                }
            }
        }
Ejemplo n.º 4
0
 public PageRuleTests()
 {
     _pageRule = new PageRule();
 }