Ejemplo n.º 1
0
        public void OptionsParseTest()
        {
            const string args = "-o directport=22"
                                + ",ssh_command=cmd"
                                + ",sftp_server=localhost"
                                + ",max_read=12"
                                + ",-1"
                                + ",idmap=none"
                                + ",idmap=user"
                                + ",no_readahead";

            bool a1 = false, a2 = false;
            int  idmap1 = 0, idmap2 = 0;
            var  options = new FuseOptions
            {
                { "directport=%u", u => Assert.Equal(22u, u) },
                { "ssh_command=%s", s => Assert.Equal("cmd", s) },
                { "-1", () => a1 = true },
                { "idmap=none", 1, i => idmap1 = i },
                { "idmap=user", 2, i => idmap2 = i },
                { "no_readahead", () => a2 = true }
            };

            var res = options.Parse(args.Split(' '));

            Assert.True(res);

            Assert.True(a1);
            Assert.True(a2);

            Assert.Equal(1, idmap1);
            Assert.Equal(2, idmap2);
        }
Ejemplo n.º 2
0
 public override void Init(FuseOptions options)
 {
     options.Add(Template, () =>
     {
         Trace.WriteLine("FlagSetter.Action called");
         _result = true;
     });
 }
Ejemplo n.º 3
0
        public void ArgsParseTest(Setter setter)
        {
            var options = new FuseOptions();

            setter.Init(options);

            var result = options.Parse(setter.Args.Split(' ', StringSplitOptions.RemoveEmptyEntries));

            Assert.True(result);
            Assert.True(setter.Success);
        }
Ejemplo n.º 4
0
        public void Test1()
        {
            var input = new List <Book>();

            input.Add(new Book
            {
                title  = "The Code of The Wooster",
                author = "Bob James"
            });

            input.Add(new Book
            {
                title  = "The Wooster Code",
                author = "Rick Martin"
            });

            input.Add(new Book
            {
                title  = "The Code",
                author = "Jimmy Charles"
            });

            input.Add(new Book
            {
                title  = "Old Man's War",
                author = "John Scalzi"
            });

            input.Add(new Book
            {
                title  = "The Lock Artist",
                author = "Steve Hamilton"
            });

            var opt = new FuseOptions <Book>();

            opt.includeMatches = true;
            opt.includeScore   = true;
            opt.keys.Add(new SearchKey <Book> {
                getter = b => b.author,
                weight = 1
            });
            opt.keys.Add(new SearchKey <Book> {
                getter = b => b.title,
                weight = 1
            });

            System.Diagnostics.Debugger.Launch();
            //var output = Fuse<Book>.Search(input, "wooster", opt);
            var output = input.FuseSearch("wooster", opt);

            Assert.True(output.Count == 5);
        }
Ejemplo n.º 5
0
        public void ExampleUsage1()
        {
            // Example copied from the docu of https://github.com/kurozael/Fuse.NET
            var input = new List <Book>();

            input.Add(new Book {
                title = "The Code of The Wooster", author = "Bob James"
            });
            input.Add(new Book {
                title = "The Wooster Code", author = "Rick Martin"
            });
            input.Add(new Book {
                title = "The Code", author = "Jimmy Charles"
            });
            input.Add(new Book {
                title = "Old Man's War", author = "John Scalzi"
            });
            input.Add(new Book {
                title = "The Lock Artist", author = "Steve Hamilton"
            });

            var opt = new FuseOptions();

            opt.includeMatches = true;
            opt.includeScore   = true;
            // Here we search through a list of `Book` types but you could search through just a list of strings.
            var fuse = new Fuse <Book>(input, opt);

            fuse.AddKey("title");
            fuse.AddKey("author");
            var searchResult = fuse.Search("woo");

            searchResult.ForEach((FuseResult <Book> res) => {
                Log.d(res.item.title + ": " + res.item.author);
                Log.d("Search Result Score: " + res.score);

                if (res.matches != null)
                {
                    res.matches.ForEach((b) => {
                        Log.d("{Match}");
                        Log.d(b.key + ": " + b.value + " (Indicies: " + b.indicies.Count + ")");
                    });
                }
            });
        }
Ejemplo n.º 6
0
 public override void Init(FuseOptions options)
 {
     options.Add(Template, s => _result = s);
 }
Ejemplo n.º 7
0
 public abstract void Init(FuseOptions options);