public void Should_Be_Possible_To_Search_SubKeys_From_KeyName()
        {
            object fakeFoundSubKeys = new string[] { "Graphics", "GData", "XPTO" };
            Dictionary<string, object> searchKeysParameters = new Dictionary<string, object>();
            searchKeysParameters.Add(registry_object_ItemsChoices.hive.ToString(), eHiveNames.HKEY_LOCAL_MACHINE.ToString());
            searchKeysParameters.Add(registry_object_ItemsChoices.key.ToString(), "Microsoft");
            
            AbstractConstraint[] invokeMethodConstraints = new AbstractConstraint[] 
                { new Equal("EnumKey"), new Anything(), new Anything() };
            
            
            MockRepository mocks = new MockRepository();
            WmiDataProvider fakeWmiPrv = mocks.DynamicMock<WmiDataProvider>();
            Expect.Call(fakeWmiPrv.InvokeMethod("", null, "")).Constraints(invokeMethodConstraints).Return(fakeFoundSubKeys);
            mocks.ReplayAll();
            
            RegistryObjectCollector systemDataSource = new RegistryObjectCollector() { WmiDataProvider = fakeWmiPrv };
            IList<string> registrySubKeys = systemDataSource.GetValues(searchKeysParameters);
            
            mocks.VerifyAll();

            Assert.IsNotNull(registrySubKeys);
            Assert.AreEqual(3, registrySubKeys.Count);
            Assert.AreEqual("Graphics", registrySubKeys[0]);
            Assert.AreEqual("GData", registrySubKeys[1]);
            Assert.AreEqual("XPTO", registrySubKeys[2]);
        }
예제 #2
0
        public void Should_Be_Possible_To_Search_KeyValues_From_KeyName()
        {
            object fakeFoundKeyValues = new List<string>(new string[] { "Risk Manager", "PCN", "Workflow Manager", "Dashboard" } );
            Dictionary<string, object> searchValuesParameters = new Dictionary<string, object>();
            searchValuesParameters.Add(registry_object_ItemsChoices.hive.ToString(), eHiveNames.HKEY_LOCAL_MACHINE.ToString());
            searchValuesParameters.Add(registry_object_ItemsChoices.key.ToString(), "SOFTWARE\\Modulo");
            searchValuesParameters.Add(registry_object_ItemsChoices.name.ToString(), "^.*");

            AbstractConstraint[] invokeMethodConstraints =
                new AbstractConstraint[] { new Equal("EnumValues"), new Anything(), new Anything() };

            MockRepository mocks = new MockRepository();
            WmiDataProvider fakeWmiPrv = mocks.DynamicMock<WmiDataProvider>();
            Expect.Call(fakeWmiPrv.InvokeMethod("", null, "")).Constraints(invokeMethodConstraints).Return(fakeFoundKeyValues);
            mocks.ReplayAll();

            RegistryObjectCollector systemDataSource = new RegistryObjectCollector() { WmiDataProvider = fakeWmiPrv };
            IList<string> registryKeyValues = systemDataSource.GetValues(searchValuesParameters);

            mocks.VerifyAll();

            Assert.IsNotNull(registryKeyValues);
            Assert.AreEqual(4, registryKeyValues.Count);
            Assert.IsTrue(registryKeyValues[0].Equals("Risk Manager"));
            Assert.IsTrue(registryKeyValues[1].Equals("PCN"));
            Assert.IsTrue(registryKeyValues[2].Equals("Workflow Manager"));
            Assert.IsTrue(registryKeyValues[3].Equals("Dashboard"));
        }