Beispiel #1
0
        public void DoFailuresWithWmiEnabled()
        {
            int numberOfEvents = 50;

            using (WmiEventWatcher eventListener = new WmiEventWatcher(numberOfEvents))
            {
                HashAlgorithmProvider          hashProvider    = new HashAlgorithmProvider(typeof(SHA1Managed), false);
                InstrumentationAttacherFactory attacherFactory = new InstrumentationAttacherFactory();
                IInstrumentationAttacher       binder          = attacherFactory.CreateBinder(hashProvider.GetInstrumentationEventProvider(), new object[] { "foo", true, true, true }, new ConfigurationReflectionCache());
                binder.BindInstrumentation();

                for (int i = 0; i < numberOfEvents; i++)
                {
                    try
                    {
                        hashProvider.CreateHash(null);
                    }
                    catch (Exception)
                    {
                    }
                }

                eventListener.WaitForEvents();

                Assert.AreEqual(numberOfEvents, eventListener.EventsReceived.Count);
            }
        }
        public void ExplicitBinderInstanceReturnedIfTwoArgumentAttributeOnSourceClass()
        {
            ExplicitBindingSource          source          = new ExplicitBindingSource();
            InstrumentationAttacherFactory factory         = new InstrumentationAttacherFactory();
            ConfigurationReflectionCache   reflectionCache = new ConfigurationReflectionCache();
            IInstrumentationAttacher       createdAttacher = factory.CreateBinder(source, new object[0], reflectionCache);

            Assert.AreSame(typeof(ExplicitInstrumentationAttacher), createdAttacher.GetType());
        }
        public void NoBinderInstanceReturnedIfNoAttributeOnSourceClass()
        {
            NoListenerSource source = new NoListenerSource();
            InstrumentationAttacherFactory factory         = new InstrumentationAttacherFactory();
            ConfigurationReflectionCache   reflectionCache = new ConfigurationReflectionCache();
            IInstrumentationAttacher       createdAttacher = factory.CreateBinder(source, new object[0], reflectionCache);

            Assert.AreSame(typeof(NoBindingInstrumentationAttacher), createdAttacher.GetType());
        }
Beispiel #4
0
        public void InstrumentationUsesExplicitBinder()
        {
            byte[] key = Guid.NewGuid().ToByteArray();

            InstrumentationAttacherFactory attacherFactory = new InstrumentationAttacherFactory();
            IInstrumentationAttacher       binder          = attacherFactory.CreateBinder(provider.GetInstrumentationEventProvider(), new object[] { "foo", true, true, true }, new ConfigurationReflectionCache());

            binder.BindInstrumentation();

            Assert.AreSame(typeof(ExplicitInstrumentationAttacher), binder.GetType());
        }