public CollectExecutionManager CreateExecutionManagerForTheSuccessScenario(ProbeResult resultForRegistry, ProbeResult resultForFamily)
        {
            MockRepository mocks = new MockRepository();

            probeManager             = mocks.DynamicMock <IProbeManager>();
            probe                    = mocks.DynamicMock <IProbe>();
            familyProbe              = mocks.DynamicMock <IProbe>();
            dataProvider             = mocks.DynamicMock <IDataProvider>();
            systemInformationService = mocks.DynamicMock <ISystemInformationService>();
            connectionContext        = this.CreateConnectionContext();

            CollectInfo collectInfo = new CollectInfo()
            {
                ObjectTypes = ovalObjects
            };

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(this.GetSelectedProbes());
            Expect.Call(probeManager.GetSystemInformationService(FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(systemInformationService);
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForRegistry);
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session).IgnoreArguments();
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session)).IgnoreArguments();
            Expect.Call(systemInformationService.GetSystemInformationFrom(target)).IgnoreArguments().Return(this.GetExpectedSystemInformation());

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
Example #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 void GetSystemInformationFromTarget(CollectRequest collectRequest, ISystemInformationService systemInformationService)
        {
            SystemInformation systemInformation = systemInformationService.GetSystemInformationFrom(Target);
            SystemInfo        systemInfo        = new SystemInfoFactory().CreateSystemInfo(systemInformation);

            collectRequest.Target.SystemInformation = systemInfo;
        }
        public CollectExecutionManager CreateExecutionManagerWithCannotConnectToHostExceptionScenario(
            ProbeResult resultForRegistry, ProbeResult resultForFamily, bool exceptionOnSystemInformationGathering = false)
        {
            MockRepository mocks = new MockRepository();

            probeManager = mocks.DynamicMock <IProbeManager>();
            probe        = mocks.DynamicMock <IProbe>();
            familyProbe  = mocks.DynamicMock <IProbe>();
            dataProvider = mocks.DynamicMock <IDataProvider>();


            var         fakeCannotConnectException = new CannotConnectToHostException(target, "Cannot Connection To Host...");
            CollectInfo collectInfo = new CollectInfo()
            {
                ObjectTypes = ovalObjects
            };

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).Repeat.Any().IgnoreArguments().Return(GetSelectedProbes());
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Throw(fakeCannotConnectException);
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session);
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session));
            if (exceptionOnSystemInformationGathering)
            {
                systemInformationService = mocks.DynamicMock <ISystemInformationService>();
                Expect.Call(probeManager.GetSystemInformationService(FamilyEnumeration.windows)).IgnoreArguments().Return(systemInformationService);
                Expect.Call(systemInformationService.GetSystemInformationFrom(null)).IgnoreArguments().Throw(fakeCannotConnectException);
            }

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
 private void GetSystemInformationFromTarget(CollectRequest collectRequest, ISystemInformationService systemInformationService)
 {
     SystemInformation systemInformation = systemInformationService.GetSystemInformationFrom(Target);
     SystemInfo systemInfo = new SystemInfoFactory().CreateSystemInfo(systemInformation);
     collectRequest.Target.SystemInformation = systemInfo;
 }