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 HashFailureThrowsWithInstrumentationEnabled()
        {
            HashAlgorithmProvider           hashProvider = new HashAlgorithmProvider(typeof(SHA1Managed), false);
            ReflectionInstrumentationBinder binder       = new ReflectionInstrumentationBinder();

            binder.Bind(hashProvider.GetInstrumentationEventProvider(), new HashAlgorithmInstrumentationListener("foo", true, true, true));

            hashProvider.CreateHash(null);
        }
Пример #3
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);
            }
        }