Example #1
0
        private ItemType[] CreateWmiItems(string nameSpace, string wql)
        {
            var newWmiItem =
                new wmi_item()
            {
                @namespace = OvalHelper.CreateItemEntityWithStringValue(nameSpace),
                wql        = OvalHelper.CreateItemEntityWithStringValue(wql)
            };

            return(new ItemType[] { newWmiItem });
        }
        public void A_wmi_item_with_error_status_must_be_returned_if_an_item_with_error_was_passed()
        {
            var fakeWmiItemWithError = new wmi_item()
            {
                status = StatusEnumeration.error
            };

            var result = new WMIObjectCollector(null).CollectDataForSystemItem(fakeWmiItemWithError).ToArray();

            ItemTypeChecker.DoBasicAssertForCollectedItems(result, 1, typeof(wmi_item), false);
            ItemTypeChecker.AssertItemTypeWithErrorStatus(result.Single().ItemType, null);
        }
Example #3
0
        private void CreateWmiDataProviderFromWmiItem(wmi_item wmiItem)
        {
            if (this.WmiDataProvider == null)
            {
                var wmiNamespace         = String.Format(@"{0}\{1}", this.TargetInfo.GetAddress(), [email protected]);
                var wmiNamespacePath     = new System.Management.ManagementPath(wmiNamespace);
                var wmiConnectionOptions = WmiDataProviderFactory.CreateConnectionOptions(this.TargetInfo);
                var wmiManagementScope   = new System.Management.ManagementScope(wmiNamespacePath, wmiConnectionOptions);
                wmiManagementScope.Connect();

                this.WmiDataProvider = new WmiDataProvider(wmiManagementScope);
            }
        }
        private void AssertWmiResultOnWmiItem(wmi_item itemToAssert, string expectedNamespace, string expectedWQL, string[] expectedResults)
        {
            Assert.AreEqual(StatusEnumeration.exists, itemToAssert.status, "An unexpected collected item status was found.");
            Assert.AreEqual(expectedNamespace, [email protected], UNEXPECTED_ENTITY_ITEM_VALUE_FOUND_ASSERT_FAIL_MSG);
            Assert.AreEqual(expectedWQL, itemToAssert.wql.Value, UNEXPECTED_ENTITY_ITEM_VALUE_FOUND_ASSERT_FAIL_MSG);

            Assert.AreEqual(expectedResults.Count(), itemToAssert.result.Count(), "An unexpected wmi records count was returned.");
            for (int i = 0; i < expectedResults.Count(); i++)
            {
                var expectedWmiFieldValue = expectedResults.ElementAt(i);
                var foundWmiFieldValue    = itemToAssert.result.ElementAt(i).Value.ToString();
                Assert.AreEqual(expectedWmiFieldValue, foundWmiFieldValue, "An unexpected item result value was found.");
            }
        }