Esempio n. 1
0
        private RegistryProber GetMockedRegistryProber(registry_item fakeItem)
        {
            var fakeValues         = new List <String>(new string[] { "FakeValue" });
            var fakeCollectedItems = new CollectedItem[] { ProbeHelper.CreateFakeCollectedItem(fakeItem) };

            MockRepository mocks                 = new MockRepository();
            var            fakeConnection        = mocks.DynamicMock <IConnectionManager>();
            var            fakeSystemInformation = mocks.DynamicMock <ISystemInformationService>();
            var            fakeProvider          = mocks.DynamicMock <RegistryConnectionProvider>();
            var            fakeWmiProvider       = new WmiDataProviderExpectFactory().GetFakeWmiDataProviderForTestInvokeMethodEnumKeyWithReturnSuccess();
            var            fakeDataCollector     = mocks.DynamicMock <RegistryObjectCollector>();

            fakeDataCollector.WmiDataProvider = fakeWmiProvider;
            var registryItemTypeGeneration = new RegistryItemTypeGenerator()
            {
                SystemDataSource = fakeDataCollector, WmiDataProvider = fakeWmiProvider
            };

            Expect.Call(fakeConnection.Connect <RegistryConnectionProvider>(null, null)).IgnoreArguments().Repeat.Any().Return(fakeProvider);
            Expect.Call(fakeDataCollector.CollectDataForSystemItem(fakeItem)).IgnoreArguments().Repeat.Any().Return(fakeCollectedItems);
            Expect.Call(fakeDataCollector.GetValues(null)).IgnoreArguments().Repeat.Any().Return(fakeValues);
            Expect.Call(fakeSystemInformation.GetSystemInformationFrom(null)).IgnoreArguments().Return(SystemInformationFactory.GetExpectedSystemInformation());
            mocks.ReplayAll();

            return(new RegistryProber()
            {
                ConnectionManager = fakeConnection, ObjectCollector = fakeDataCollector, ItemTypeGenerator = registryItemTypeGeneration
            });
        }
Esempio n. 2
0
        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
            });
        }
 private SystemInformation GetExpectedSystemInformation()
 {
     return(SystemInformationFactory.GetExpectedSystemInformation());
 }
Esempio n. 4
0
        private FamilyProberWindows GetFamilyProber()
        {
            MockRepository mocks = new MockRepository();
            var            fakeFamilyDataSource   = mocks.DynamicMock <BaseObjectCollector>();
            var            fakeInformationService = mocks.DynamicMock <ISystemInformationService>();
            var            fakeConnectionManager  = mocks.DynamicMock <IConnectionManager>();

            Expect.Call(fakeFamilyDataSource.CollectDataForSystemItem(null)).IgnoreArguments().Return(this.createFakeFamilyItem());
            Expect.Call(fakeInformationService.GetSystemInformationFrom(null)).IgnoreArguments().Return(SystemInformationFactory.GetExpectedSystemInformation());
            mocks.ReplayAll();

            return(new FamilyProberWindows()
            {
                ObjectCollector = fakeFamilyDataSource, ConnectionManager = fakeConnectionManager
            });
        }