private void StartProfiling(object arg) { ProfilingOperations profiling = (ProfilingOperations)arg; switch (profiling) { case ProfilingOperations.Executable: ProfilingProcess = new ExecutableProfilingOperation(); break; case ProfilingOperations.Process: ProfilingProcess = new ProcessProfilingOperation(); break; case ProfilingOperations.IIS: ProfilingProcess = new IISProfilingOperation(); break; default: return; } RaisePropertyChanged("ProfilingProcess"); ProfilingProcess.ProfilingFinished += ProfilingProcessProfilingFinished; ProfilingProcess.StartProfiling(); }
public void ExecutableOperationTest1() { var process = new Mock <IProcess>(); var processProvider = new Mock <IProcessProvider>(); var processStartInfo = new ProcessStartInfo(); processProvider.Setup(x => x.Start(It.IsAny <ProcessStartInfo>())).Returns(process.Object).Callback <ProcessStartInfo>(x => processStartInfo = x); _container.RegisterInstance(typeof(IProcessProvider), processProvider.Object); var executableProfiling = new ExecutableProfilingOperation(); executableProfiling.StartProfiling(); executableProfiling.DetachProfiler(); Assert.AreEqual(_fileSystem.Object.OpenFileDialog(string.Empty), processStartInfo.FileName); Assert.IsTrue(processStartInfo.EnvironmentVariables.ContainsKey(Constants.Cor_Enable_Profiling)); Assert.IsTrue(processStartInfo.EnvironmentVariables.ContainsKey(Constants.Cor_Profiler)); Assert.IsTrue(processStartInfo.EnvironmentVariables.ContainsKey(Constants.Threshold)); Assert.IsTrue(processStartInfo.EnvironmentVariables.ContainsKey(Constants.TmpFolderName)); }
public void ExecutableOperationTest2() { var encoding = new System.Text.UTF8Encoding(); _fileSystem.Setup(x => x.OpenFileRead(It.IsAny <string>())).Returns(new MemoryStream(encoding.GetBytes(MockResult))); _fileSystem.Setup(x => x.FileExist(It.IsAny <string>())).Returns(true); var process = new Mock <IProcess>(); var processProvider = new Mock <IProcessProvider>(); processProvider.Setup(x => x.Start(It.IsAny <ProcessStartInfo>())).Returns(process.Object); _container.RegisterInstance(typeof(IProcessProvider), processProvider.Object); var executableProfiling = new ExecutableProfilingOperation(); bool profilingFinishedRaised = false; executableProfiling.ProfilingFinished += () => profilingFinishedRaised = true; executableProfiling.StartProfiling(); process.Raise(x => x.Exited += null, process, new EventArgs()); Assert.IsNotNull(executableProfiling.Results.MethodInfos); Assert.IsTrue(profilingFinishedRaised); }