private FileProber GetMockedFileProber(file_item fakeItem) { IList <String> fakeValues = new List <String>(new string[] { "FakeValue" }); CollectedItem fakeCollectedItem = ProbeHelper.CreateFakeCollectedItem(fakeItem); MockRepository mocks = new MockRepository(); IConnectionManager fakeConnection = mocks.DynamicMock <IConnectionManager>(); ISystemInformationService fakeSystemInformation = mocks.DynamicMock <ISystemInformationService>(); FileConnectionProvider fakeProvider = mocks.DynamicMock <FileConnectionProvider>(); WmiDataProvider fakeWmiProvider = mocks.DynamicMock <WmiDataProvider>(); FileObjectCollector fakeDataCollector = mocks.DynamicMock <FileObjectCollector>(); fakeDataCollector.WmiDataProvider = fakeWmiProvider; //Expect.Call(fakeConnection.Connect<FileConnectionProvider>(null, null)).IgnoreArguments().Repeat.Any().Return(fakeProvider); Expect.Call(fakeDataCollector.CollectDataForSystemItem(fakeItem)).IgnoreArguments().Repeat.Any().Return(new List <CollectedItem>() { fakeCollectedItem }); Expect.Call(fakeDataCollector.GetValues(null)).IgnoreArguments().Repeat.Any().Return(fakeValues); Expect.Call(fakeSystemInformation.GetSystemInformationFrom(null)).IgnoreArguments().Return(SystemInformationFactory.GetExpectedSystemInformation()); mocks.ReplayAll(); return(new FileProber() { ConnectionManager = fakeConnection, ObjectCollector = fakeDataCollector }); }
public void Should_be_possible_to_collect_a_fileItem_without_filename_information() { var fileItem = new file_item() { path = OvalHelper.CreateItemEntityWithStringValue("c:\\windows"), filename = OvalHelper.CreateItemEntityWithStringValue(string.Empty) }; var fileObjectCollector = new FileObjectCollector() { WmiDataProvider = GetMockedWmiDataProvider() }; var collectedObjects = fileObjectCollector.CollectDataForSystemItem(fileItem); }