コード例 #1
0
        static void TestDictionaryQuery()
        {
            using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("assembly"))
            {
                dic.ShouldSatisfyAllConditions(
                    () => dic.ShouldContainKey("done"),
                    () => dic.ShouldContainKey("Name"),
                    () => dic["Name"].ShouldBe(Assembly.GetExecutingAssembly().FullName)
                    );

                dynamic dyn = dic.AsDynamic();
                (dyn.Name as object).ShouldBe(dic["Name"]);

                dyn.Name = Assembly.GetExecutingAssembly().GetName().Name;
                dic["Name"].ShouldBe(Assembly.GetExecutingAssembly().GetName().Name);

                dic["Name"] = Assembly.GetExecutingAssembly().FullName;
            }
        }
コード例 #2
0
        static void TestParallelModifications()
        {
            using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("parallel"))
            {
                dic.Add("hello", "world");
                dic["hello"].ShouldBe("world");

                using (DictionaryQuery <string> pdic = cx.DictionaryQuery <string>("parallel"))
                {
                    pdic["hello"] = "you";
                }

                dic.ShouldContainKey("hello");
                dic["hello"].ShouldBe("you");
                dic.Clear();
            }
        }