예제 #1
0
        static void TestAddTag(string expr, string tag, string expectedParenthesizedResultExpr)
        {
            var p = TagsPredicate.Parse(expr);

            p = p.Add(tag);
            Assert.AreEqual(expectedParenthesizedResultExpr, p.ToString('p'), $"'{expr}' + '{tag}' must be '{expectedParenthesizedResultExpr}'");
        }
예제 #2
0
        static void TestMatch(string expr, bool expectMatch, params string[] tags)
        {
            var p       = TagsPredicate.Parse(expr);
            var isMatch = p.IsMatch(new HashSet <string>(tags));

            Assert.AreEqual(expectMatch, isMatch, $"{expr} matches [${string.Join(" ", tags)}]?, expected ${expectMatch}");
        }
예제 #3
0
        static void TestUsedTags(string expr, params string[] expectedTags)
        {
            var p      = TagsPredicate.Parse(expr);
            var actual = p.UsedTags.Select(tag => tag.Item1).ToHashSet();

            Assert.AreEqual(true, actual.SetEquals(expectedTags), $"{expr} must have used tags ${string.Join(",", expectedTags)}");
        }
예제 #4
0
 static void TestParse(string str, string parenthesizedExpr, string parentheseslessExpr, string error = null)
 {
     try
     {
         var p = TagsPredicate.Parse(str);
         Assert.AreEqual(parenthesizedExpr, p.ToString('p'));
         Assert.AreEqual(parentheseslessExpr, p.ToString());
     }
     catch (TagsPredicate.SyntaxError e)
     {
         Assert.AreEqual(error, $"{e.Message} at {e.Position}");
     }
 }
예제 #5
0
 public void BeforeEach()
 {
     model      = Substitute.For <IPostprocessorTags>();
     view       = Substitute.For <IView>();
     dialogView = Substitute.For <IDialogView>();
     alerts     = Substitute.For <IAlertPopup>();
     view.When(v => v.SetViewModel(Arg.Any <IViewModel>())).Do(x => viewModel = x.Arg <IViewModel>());
     view.CreateDialog(Arg.Do <IDialogViewModel>(x => dialogViewModel         = x), Arg.Any <IEnumerable <string> >(), Arg.Any <string>()).Returns(dialogView);
     changeNotification = Substitute.For <IChangeNotification>();
     model.AvailableTags.Returns(ImmutableHashSet.Create(new[] { "foo", "bar", "item-1", "item-2", "abd", "abc" }));
     model.TagsPredicate.Returns(TagsPredicate.Parse("bar OR item-1 AND NOT abc"));
     presenter = new TagsListPresenter(
         model,
         view,
         changeNotification,
         alerts
         );
 }