public void Should_be_possible_to_collect_SIDObject_for_given_trusteeName() { IList <WmiObject> fakeWmiObjects = new List <WmiObject>(); fakeWmiObjects.Add(this.createFakeWmiObject("MSS", "lfernandes", "FALSE", "Win32_UserAccount")); SIDObjectCollector systemDataSource = this.CreateMockedSIDSystemDatasource(fakeWmiObjects); string expectedSID = fakeWmiObjects[0].GetValueOf("SID").ToString(); IEnumerable <CollectedItem> collectedItems = systemDataSource.CollectDataForSystemItem(this.createFakeSidItem()); Assert.IsNotNull(collectedItems, "The collected items cannot be null."); Assert.AreEqual(1, collectedItems.Count(), "Unexpected collected items count."); CollectedItem collectedItem = collectedItems.First(); Assert.IsNotNull(collectedItem.ExecutionLog, "The execution log cannot be null."); Assert.AreEqual(1, collectedItem.ExecutionLog.Count(), "Unexpected execution log count."); Assert.AreEqual(TypeItemLog.Info, collectedItem.ExecutionLog.First().Type, "The type of execution log should be Info."); Assert.IsInstanceOfType(collectedItem.ItemType, typeof(sid_item), "The type of collected item type should be 'sid_item'."); Assert.AreEqual(StatusEnumeration.exists, collectedItem.ItemType.status, "The status of collected item should be 'exists'."); Assert.AreEqual("lfernandes", ((sid_item)collectedItem.ItemType).trustee_name.Value, "Unexpected trustee name was found on collected SID Item."); Assert.AreEqual("MSS", ((sid_item)collectedItem.ItemType).trustee_domain.Value, "Unexpected trustee domain was found on collected SID Item."); Assert.AreEqual(expectedSID, ((sid_item)collectedItem.ItemType).trustee_sid.Value, "Unexpected trustee SID was found on collected SID Item."); }
public void Should_be_possible_to_get_all_SIDObjects_from_target() { // Arrange IList <WmiObject> fakeWmiObjects = new List <WmiObject>(); fakeWmiObjects.Add(this.createFakeWmiObject("MSS", "lfernandes", "FALSE", "Win32_UserAccount")); fakeWmiObjects.Add(this.createFakeWmiObject("MSS-RJ-001", "Administrators", "TRUE", "Win32_Group")); fakeWmiObjects.Add(this.createFakeWmiObject("MSS-RJ-001", "NETWORK SERVICE", "TRUE", "Win32_SystemAccount")); SIDObjectCollector systemDataSource = this.CreateMockedSIDSystemDatasource(fakeWmiObjects); // Act IList <string> searchSystemObjectResult = systemDataSource.GetValues(null); // Assert Assert.IsNotNull(searchSystemObjectResult, "The result of get system objects cannot be null."); Assert.AreEqual(3, searchSystemObjectResult.Count, "Unexpected system objects count."); Assert.AreEqual(@"MSS\lfernandes", searchSystemObjectResult[0], "Unexpected account caption found."); Assert.AreEqual(@"MSS-RJ-001\Administrators", searchSystemObjectResult[1], "Unexpected account caption found."); Assert.AreEqual(@"MSS-RJ-001\NETWORK SERVICE", searchSystemObjectResult[2], "Unexpected account caption found."); }