~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplication.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// <file>
 
2
//     <copyright see="prj:///doc/copyright.txt"/>
 
3
//     <license see="prj:///doc/license.txt"/>
 
4
//     <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
 
5
//     <version>$Revision$</version>
 
6
// </file>
 
7
 
 
8
using System;
 
9
using System.Collections.Generic;
 
10
using System.Diagnostics;
 
11
using System.Text;
 
12
using ICSharpCode.Core;
 
13
using ICSharpCode.UnitTesting;
 
14
 
 
15
namespace Gallio.SharpDevelop
 
16
{
 
17
        public class GallioEchoConsoleApplication
 
18
        {
 
19
                string fileName = String.Empty;
 
20
                SelectedTests selectedTests;
 
21
                StringBuilder commandLine = new StringBuilder();
 
22
                List<TestRunnerExtensionCommandLineArgument> testRunnerExtensions = 
 
23
                        new List<TestRunnerExtensionCommandLineArgument>();
 
24
                
 
25
                public GallioEchoConsoleApplication(SelectedTests selectedTests, string fileName)
 
26
                {
 
27
                        this.selectedTests = selectedTests;
 
28
                        this.fileName = fileName;
 
29
                }
 
30
                
 
31
                public GallioEchoConsoleApplication(SelectedTests selectedTests)
 
32
                        : this(selectedTests, String.Empty)
 
33
                {
 
34
                }
 
35
                
 
36
                public string FileName {
 
37
                        get { return fileName; }
 
38
                }
 
39
                
 
40
                public List<TestRunnerExtensionCommandLineArgument> TestRunnerExtensions {
 
41
                        get { return testRunnerExtensions; }
 
42
                }
 
43
                
 
44
                public string GetArguments()
 
45
                {
 
46
                        AppendDotNet4Framework();
 
47
                        AppendTestRunnerExtensions();
 
48
                        AppendAssemblyToTest();
 
49
                        
 
50
                        return commandLine.ToString().TrimEnd();
 
51
                }
 
52
                
 
53
                void AppendDotNet4Framework()
 
54
                {
 
55
                        AppendArgument("/rv:v4.0.30319");
 
56
 
 
57
                }
 
58
                
 
59
                void AppendTestRunnerExtensions()
 
60
                {
 
61
                        foreach (TestRunnerExtensionCommandLineArgument arg in testRunnerExtensions) {
 
62
                                AppendArgument(arg.ToString());
 
63
                        }
 
64
                }
 
65
                
 
66
                void AppendArgument(string argument)
 
67
                {
 
68
                        commandLine.Append(argument);
 
69
                        commandLine.Append(' ');
 
70
                }
 
71
                
 
72
                void AppendAssemblyToTest()
 
73
                {
 
74
                        AppendQuoted(selectedTests.Project.OutputAssemblyFullPath);
 
75
                }
 
76
                
 
77
                void AppendQuoted(string argument)
 
78
                {
 
79
                        commandLine.AppendFormat("\"{0}\"", argument);
 
80
                }
 
81
                
 
82
                public ProcessStartInfo GetProcessStartInfo()
 
83
                {
 
84
                        ProcessStartInfo startInfo = new ProcessStartInfo();
 
85
                        startInfo.FileName = fileName;
 
86
                        startInfo.Arguments = GetArguments();
 
87
                        startInfo.WorkingDirectory = GetWorkingDirectory();
 
88
                        return startInfo;
 
89
                }
 
90
                
 
91
                string GetWorkingDirectory()
 
92
                {
 
93
                        return StringParser.Parse("${addinpath:ICSharpCode.Gallio}");
 
94
                }
 
95
        }
 
96
}