示例#1
0
        public void test()
        {
            IRoseTree <string, Command> editMenu =
                from name in editMenuTemplate
                select commandStore.Lookup(name).GetOrElse(new Command(name));

            Maybe <Command> find;


            using StringWriter sw = new StringWriter();

            Console.SetOut(sw);
            find = editMenu.Find(e => e.Name == "Find");
            var findAll = editMenu.FindAll(e => e.Name == "Find" || e.Name == "Copy");

            var concat = editMenu.Fold((acc, c) => acc + c.Name, "");

            find.Match(Nothing: () => { }, Just: c => c.Execute());

            Assert.Equal($"Find\r\n", sw.ToString());
        }