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 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()); }
private void BindInstrumentationTo(object createdObject, object[] constructorArgs, ConfigurationReflectionCache reflectionCache) { IInstrumentationAttacher attacher = attacherFactory.CreateBinder(createdObject, constructorArgs, reflectionCache); attacher.BindInstrumentation(); }