public VanguardTests() { TestCase testcase = new TestCase { Id = Guid.NewGuid() }; this.dataCollectionContext = new DataCollectionContext(testcase); this.dataCollectionLoggerMock = new Mock <IDataCollectionLogger>(); this.processJobObject = new ProcessJobObject(); this.vanguardCommandBuilderMock = new Mock <IVanguardCommandBuilder>(); this.vanguardLocationProviderMock = new Mock <IProfilersLocationProvider>(); this.vanguard = new Vanguard(this.vanguardLocationProviderMock.Object, this.vanguardCommandBuilderMock.Object, this.processJobObject); this.sessionName = Guid.NewGuid().ToString(); this.configFileName = string.Format(VanguardTests.ConfigFileNameFormat, Path.GetTempPath(), this.sessionName); this.outputDir = Path.GetDirectoryName(this.configFileName); Directory.CreateDirectory(this.outputDir); File.WriteAllText(this.configFileName, VanguardTests.ConfigXml); this.outputFileName = Path.Combine(this.outputDir, Guid.NewGuid() + ".coverage"); this.vanguardCommandBuilderMock.Setup(c => c.GenerateCommandLine(VanguardCommand.Shutdown, this.sessionName, It.IsAny <string>(), It.IsAny <string>())) .Returns(VanguardTests.GetShutdownCommand(this.sessionName)); this.vanguard.Initialize(this.sessionName, this.configFileName, this.dataCollectionLoggerMock.Object); this.vanguardLocationProviderMock.Setup(c => c.GetVanguardPath()).Returns(Path.Combine(Directory.GetCurrentDirectory(), "CodeCoverage", "CodeCoverage.exe")); }
internal Vanguard( IVanguardLocationProvider vanguardLocationProvider, IVanguardCommandBuilder commandBuilder, IProcessJobObject processJobObject) { this.vanguardLocationProvider = vanguardLocationProvider; this.vanguardCommandBuilder = commandBuilder; this.processJobObject = processJobObject; }
/// <inheritdoc /> public virtual void Stop() { EqtTrace.Info("Vanguard.Stop: Stopping Vanguard."); if (this.IsRunning) { var shutdownCommand = this.vanguardCommandBuilder.GenerateCommandLine( VanguardCommand.Shutdown, this.sessionName, null, null); this.StartVanguardProcess(shutdownCommand, true); if (this.vanguardProcessExitEvent.WaitOne(ProcessExitWaitLimit) == false) { EqtTrace.Warning("Vanguard.Stop: Vanguard process not exited in {0} ms", ProcessExitWaitLimit); } if (this.processJobObject != null) { this.processJobObject.Dispose(); this.processJobObject = null; } } }