public List<TestRunUnitTestResult> GetAllPassesTests(TestRun testRun)
 {
     List<TestRunUnitTestResult> results = new List<TestRunUnitTestResult>();
     
     results = testRun.Results.ToList().Where(x => x.outcome.Equals("Passed")).ToList();
     return results;
 }
 public void SerializeTestRun(TestRun updatedTestRun)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(TestRun));
     TextWriter writer = new StreamWriter(this.consoleArgumentsProvider.NewTestResultPath);
     using (writer)
     {
         serializer.Serialize(writer, updatedTestRun); 
     }
 }
 public void UpdateResultsSummary(TestRun testRun)
 {
     testRun.ResultSummary.Counters.failed = (byte)testRun.Results.ToList().Count(x => x.outcome.Equals("Failed"));
     testRun.ResultSummary.Counters.passed = (byte)testRun.Results.ToList().Count(x => x.outcome.Equals("Passed"));
     if ((int)testRun.ResultSummary.Counters.passed != testRun.Results.Length)
     {
         testRun.ResultSummary.outcome = "Failed";
     }
     else
     {
         testRun.ResultSummary.outcome = "Passed";
     }
 }
 public void ExecuteOnlyOnce_WhenRetriestCountSetToOneAndNoFailedTestsPresent()
 {
     var log = Mock.Create<ILog>();
     Mock.Arrange(() => log.Info(Arg.AnyString));             
     var consoleArgumentsProvider = Mock.Create<IConsoleArgumentsProvider>();
     string newFileName = Path.GetTempFileName();
     Mock.Arrange(() => consoleArgumentsProvider.NewTestResultPath).Returns(newFileName);
     Mock.Arrange(() => consoleArgumentsProvider.TestResultPath).Returns("Exceptions.trx");
     Mock.Arrange(() => consoleArgumentsProvider.ConsoleArguments).Returns("ipconfig");
     Mock.Arrange(() => consoleArgumentsProvider.RetriesCount).Returns(1);
     var processExecutionProvider = Mock.Create<IProcessExecutionProvider>();
     Mock.Arrange(() => processExecutionProvider.ExecuteProcessWithAdditionalArguments(string.Empty)).DoNothing();
     Mock.Arrange(() => processExecutionProvider.CurrentProcessWaitForExit()).DoNothing();
     var fileSystemProvider = Mock.Create<IFileSystemProvider>();
     Mock.Arrange(() => fileSystemProvider.SerializeTestRun(Arg.IsAny<TestRun>())).DoNothing();
     TestRun testRun = new TestRun();
     var testRunUnitTestResult = new TestRunUnitTestResult()
     {
         outcome = "Passed"
     };
     testRun.Results = new TestRunUnitTestResult[]
     {
         testRunUnitTestResult,
         testRunUnitTestResult
     };
     testRun.ResultSummary = new TestRunResultSummary();
     testRun.ResultSummary.outcome = "Passed";
     Mock.Arrange(() => fileSystemProvider.DeserializeTestRun(Arg.AnyString)).Returns(testRun);
     var microsoftTestRunProvider = Mock.Create<IMsTestTestRunProvider>();
   
     Mock.Arrange(() => microsoftTestRunProvider.GetAllPassesTests(Arg.IsAny<TestRun>())).DoNothing();
     Mock.Arrange(() => microsoftTestRunProvider.UpdatePassedTests(Arg.IsAny<List<TestRunUnitTestResult>>(), Arg.IsAny<List<TestRunUnitTestResult>>())).DoNothing();
     Mock.Arrange(() => microsoftTestRunProvider.UpdateResultsSummary(Arg.IsAny<TestRun>())).DoNothing();
     Mock.Arrange(() => microsoftTestRunProvider.GetAllNotPassedTests(Arg.IsAny<List<TestRunUnitTestResult>>())).Returns(new List<TestRunUnitTestResult>() { });
     Mock.Arrange(() => microsoftTestRunProvider.GenerateAdditionalArgumentsForFailedTestsRun(Arg.IsAny<List<TestRunUnitTestResult>>(), Arg.AnyString)).DoNothing();
   
     var engine = new TestExecutionService(
         microsoftTestRunProvider,
         fileSystemProvider,
         processExecutionProvider,
         consoleArgumentsProvider,
         log);
     int result = engine.ExecuteWithRetry();
     Mock.Assert(() => fileSystemProvider.SerializeTestRun(Arg.IsAny<TestRun>()), Occurs.Exactly(1));
     Assert.AreEqual<int>(0, result);
 }