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

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

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

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).IgnoreArguments().Return(GetSelectedProbes());
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).Throw(new InvalidCredentialsException("The credentials is not valid", null));
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session).IgnoreArguments();
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session)).IgnoreArguments();

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
        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
            });
        }
        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
            });
        }