public void Should_be_possible_to_collect_a_simple_groupSID_object() { var fakeItemToCollect = new group_sid_item() { group_sid = OvalHelper.CreateItemEntityWithStringValue("S-1-32-500") }; var fakeGroupAccount = new WindowsGroupAccount() { UserSIDs = new string[] { "S-1-0", "S-1-1" }.ToList() }; GroupSIDObjectCollector systemDataSource = this.createMockedGroupSIDSystemDataSource(fakeGroupAccount); var result = systemDataSource.CollectDataForSystemItem(fakeItemToCollect); Assert.IsNotNull(result, "The result of collect cannot be null."); Assert.AreEqual(1, result.Count(), "Unexpected number of collected objects was found."); Assert.IsNotNull(result.ElementAt(0).ExecutionLog, "The execution log for collected item cannot be null."); group_sid_item collectedItem = (group_sid_item)result.ElementAt(0).ItemType; Assert.AreEqual(StatusEnumeration.exists, collectedItem.status, "Invalid Item Type Status was found."); Assert.AreEqual("S-1-32-500", collectedItem.group_sid.Value, "Unexpected item type value was found."); Assert.AreEqual(2, collectedItem.user_sid.Count(), "Unexpected number of user SIDs was found in collected group_sid_item."); Assert.AreEqual("S-1-0", collectedItem.user_sid.ElementAt(0).Value, "A unexpected group SID was found in collected group_sid_item."); Assert.AreEqual("S-1-1", collectedItem.user_sid.ElementAt(1).Value, "A unexpected group SID was found in collected group_sid_item."); }
private GroupSIDObjectCollector createMockedGroupSIDSystemDataSource(WindowsGroupAccount fakeWindowsGroupAccountToReturn) { MockRepository mocks = new MockRepository(); var fakeWmiDataProvider = mocks.DynamicMock <WmiDataProvider>(); var fakeGroupProvider = mocks.DynamicMock <WindowsGroupAccountProvider>(null, null); Expect.Call(fakeGroupProvider.CollectWindowsGroupAccountInfoBySID(null)).IgnoreArguments().Return(fakeWindowsGroupAccountToReturn); mocks.ReplayAll(); return(new GroupSIDObjectCollector() { TargetInfo = FakeTargetInfo, WmiDataProvider = fakeWmiDataProvider, WindowsGroupProvider = fakeGroupProvider }); }