public void When_it_was_not_possible_to_establish_a_connection_to_target_the_status_of_collect_result_must_be_error()
        {
            IDocumentSession fakeSession = provider.GetSession();
            var fakeRequestCollect = this.GetCollectRequest();
            var definitions = new OvalDocumentLoader().GetFakeOvalDefinitions("definitionsWithLocalVariable.xml");
            var newDefinitiondoc = new DefinitionDocument() { OriginalId = "01", Text = definitions.GetDefinitionsXml() };
            session.Store(newDefinitiondoc);
            fakeRequestCollect.OvalDefinitionsId = newDefinitiondoc.Oid;
            
            var factory = new CollectExecutionManagerFactory(fakeRequestCollect, session);
            var executionManager =
                factory
                    .CreateExecutionManagerWithCannotConnectToHostExceptionScenario(
                        this.GetResultForRegistry(fakeRequestCollect, new List<String>()),
                        this.GetResultForFamily(fakeRequestCollect, new string[] { "oval:org.mitre.oval:obj:1000" }.ToList()),
                        true);

            //fakeRequestCollect.Collects.Add(new CollectExecution(session));
            //fakeRequestCollect.Collects.Add(new CollectExecution(session));
            //fakeRequestCollect.Collects.Add(new CollectExecution(session));
            session.SaveChanges();
            executionManager.ExecuteCollect(fakeSession, fakeRequestCollect, FamilyEnumeration.windows);
            

            var requestCollectAfterExecution = session.Load<CollectRequest>(fakeRequestCollect.Oid);
            Assert.AreEqual(CollectStatus.Error, requestCollectAfterExecution.Result.Status);
        }
        public void Should_be_possible_finalize_the_collectRequest_if_the_number_of_execution_exceeds_of_limits()
        {
            IDocumentSession fakeSession = provider.GetSession();
            CollectRequest collectRequest = this.GetCollectRequest();
            oval_definitions definitions = new OvalDocumentLoader().GetFakeOvalDefinitions("definitionsWithLocalVariable.xml");
            var objList = new List<ObjectType>();
            objList.Add(new family_object() { id = "oval:org.mitre.oval:obj:1000" });
            objList.Add(new file_object() { id = "oval:org.mitre.oval:obj:5000" });
            definitions.objects = objList.ToArray();

            var newDefinitiondoc = new DefinitionDocument() { OriginalId = "01", Text = definitions.GetDefinitionsXml() };
            session.Store(newDefinitiondoc);
            collectRequest.OvalDefinitionsId = newDefinitiondoc.Oid;
            CollectExecutionManagerFactory factory = new CollectExecutionManagerFactory(collectRequest, session);
            List<string> registryObjectsThatNotProcessInFirstTime = new List<string>();
            List<string> familyObjectsThatNotProcessInFirstTime = new List<string>();
            CollectExecutionManager executionManager = factory.CreateExecutionManagerForTheSuccessScenario(this.GetResultForRegistry(collectRequest, registryObjectsThatNotProcessInFirstTime),
                                                                                                           this.GetResultForFamily(collectRequest, familyObjectsThatNotProcessInFirstTime));

            session.Store(collectRequest);
            var newExecution1 = new CollectExecution() { RequestId = collectRequest.Oid };
            session.Store(newExecution1);
            var newExecution2 = new CollectExecution() { RequestId = collectRequest.Oid };
            session.Store(newExecution2);
            var newExecution3 = new CollectExecution() { RequestId = collectRequest.Oid };
            session.Store(newExecution3);
            executionManager.ExecuteCollect(fakeSession, collectRequest, FamilyEnumeration.windows);
            session.SaveChanges();

            CollectRequest collectRequestAfterExecute = session.Load<CollectRequest>(collectRequest.Oid.ToString());  
            Assert.IsNotNull(collectRequest);
            Assert.AreEqual(4, collectRequestAfterExecute.GetNumberOfExecutions(session));
            Assert.IsTrue(collectRequestAfterExecute.isClosed());
        }