private void ChangeNotificationTestHelper <TPackageInfo, TPackage>(
            ChangeNotificationTestData <TPackageInfo, TPackage> data,
            TPackageInfo oldPackage,
            TPackageInfo newPackage,
            Action <EventArgs> validator)
            where TPackageInfo : IPackageInfo
            where TPackage : class
        {
            var stub = new CodePackageActivationContextStub();

            // create the context
            var context = new CodePackageActivationContext(stub);

            EventArgs packageChangedArgs = null;

            // create a delegate for handling the event
            Action <object, EventArgs> eventHandler = (sender, args) =>
            {
                Assert.AreSame(context, sender);

                packageChangedArgs = args;
            };

            // hookup the delegate as the event handler
            data.EventHookupFunction(context, eventHandler);

            // invoke the event
            data.EventInvoker(stub, oldPackage, newPackage);

            // validate that the event was invoked
            Assert.IsNotNull(packageChangedArgs);

            validator(packageChangedArgs);
        }
        private void OneHandlerRegistrationTestHelper(Func <CodePackageActivationContextStub, int> handlerCountFunc)
        {
            var stub = new CodePackageActivationContextStub();

            var context = new CodePackageActivationContext(stub);

            Assert.AreEqual <int>(1, handlerCountFunc(stub));
        }
        private static void SimplePropertiesOnContextObjectTest(
            Action <CodePackageActivationContextStub, string> setter,
            Func <CodePackageActivationContext, string> getter)
        {
            const string text = "abc";
            var          stub = new CodePackageActivationContextStub();

            setter(stub, text);

            var context = CodePackageActivationContext.CreateFromNative(stub);

            Assert.AreEqual(text, getter(context));
        }