Esempio n. 1
0
        public void RetrieveCachedPrincipalFiresWmiEvent()
        {
            SecurityCacheProvider securityCache = SecurityCacheFactory.GetSecurityCacheProvider() as SecurityCacheProvider;
            SecurityCacheProviderInstrumentationListener listener = new SecurityCacheProviderInstrumentationListener("foo", false, false, true);

            ReflectionInstrumentationBinder binder = new ReflectionInstrumentationBinder();

            binder.Bind(securityCache.GetInstrumentationEventProvider(), listener);

            using (WmiEventWatcher eventWatcher = new WmiEventWatcher(1))
            {
                IToken token   = new GuidToken();
                object profile = securityCache.GetPrincipal(token);
                eventWatcher.WaitForEvents();

                Assert.AreEqual(1, eventWatcher.EventsReceived.Count);
                Assert.AreEqual("SecurityCacheReadPerformedEvent", eventWatcher.EventsReceived[0].ClassPath.ClassName);
                Assert.AreEqual(SecurityEntityType.Principal.ToString(), eventWatcher.EventsReceived[0].Properties["EntityType"].Value);
                Assert.AreEqual("foo", eventWatcher.EventsReceived[0].Properties["InstanceName"].Value);
                Assert.AreEqual(token.Value, eventWatcher.EventsReceived[0].Properties["TokenUsed"].Value);
            }
        }
 public void Setup()
 {
     _securities    = new Dictionary <Symbol, Security>();
     _cacheProvider = new SecurityCacheProvider(this);
 }