Beispiel #1
0
            public override void AfterPopulateProperties(ArgHook.HookContext context)
            {
                Assert.IsTrue(context.HasProperty("Year"));
                Assert.IsTrue(context.HasProperty("Name"));

                var year = context.GetProperty<int>("Year");
                var name = context.GetProperty<string>("Name");

                Assert.AreEqual(2013, year);
                Assert.AreEqual("Adam", name);

                context.ClearProperty("Year");
                context.SetProperty<string>("Name", null);

                Assert.IsFalse(context.HasProperty("Year"));
                Assert.IsFalse(context.HasProperty("Name"));

                Assert.IsNull(context.GetProperty<string>("Name"));

                try
                {
                    context.GetProperty<int>("Year");
                    Assert.Fail("An exception should have been thrown");
                }
                catch (KeyNotFoundException)
                {
                    // Throw for value types, return null for reference types
                }

                WasRun = true;
            }