~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingHost.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
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.CodeDom.Compiler;
 
6
using System.Text;
 
7
 
 
8
using ICSharpCode.TextTemplating;
 
9
 
 
10
namespace TextTemplating.Tests.Helpers
 
11
{
 
12
        public class FakeTextTemplatingHost : ITextTemplatingHost
 
13
        {
 
14
                public string InputFilePassedToProcessTemplate;
 
15
                public string OutputFilePassedToProcessTemplate;
 
16
                public bool ProcessTemplateReturnValue = true;
 
17
                
 
18
                public string InputFilePassedToPreprocessTemplate;
 
19
                public Encoding EncodingPassedToPreprocessTemplate;
 
20
                public string ClassNamePassedToPreprocessTemplate;
 
21
                public string ClassNamespacePassedToPreprocessTemplate;
 
22
                public string OutputFilePassedToPreprocessTemplate;
 
23
                public bool PreprocessTemplateReturnValue = true;
 
24
                public string PreprocessTemplateLanguageOutParameter;
 
25
                public string[] PreprocessTemplateReferencesOutParameter;
 
26
                
 
27
                public bool IsDisposeCalled;
 
28
                public Exception ExceptionToThrowWhenProcessTemplateCalled;
 
29
                
 
30
                public Exception ExceptionToThrowWhenPreprocessTemplateCalled;
 
31
                
 
32
                public CompilerErrorCollection ErrorsCollection = new CompilerErrorCollection();
 
33
                
 
34
                public CompilerErrorCollection Errors {
 
35
                        get { return ErrorsCollection; }
 
36
                }
 
37
                
 
38
                public bool ProcessTemplate(string inputFile, string outputFile)
 
39
                {
 
40
                        InputFilePassedToProcessTemplate = inputFile;
 
41
                        OutputFilePassedToProcessTemplate = outputFile;
 
42
                        
 
43
                        if (ExceptionToThrowWhenProcessTemplateCalled != null) {
 
44
                                throw ExceptionToThrowWhenProcessTemplateCalled;
 
45
                        }
 
46
                        
 
47
                        return ProcessTemplateReturnValue;
 
48
                }
 
49
                
 
50
                public void Dispose()
 
51
                {
 
52
                        IsDisposeCalled = true;
 
53
                }
 
54
                
 
55
                public string OutputFile { get; set; }
 
56
                
 
57
                public bool PreprocessTemplate (
 
58
                        string inputFile,
 
59
                        string className,
 
60
                        string classNamespace,
 
61
                        string outputFile,
 
62
                        Encoding encoding,
 
63
                        out string language,
 
64
                        out string[] references)
 
65
                {
 
66
                        InputFilePassedToPreprocessTemplate = inputFile;
 
67
                        ClassNamePassedToPreprocessTemplate = className;
 
68
                        ClassNamespacePassedToPreprocessTemplate = classNamespace;
 
69
                        OutputFilePassedToPreprocessTemplate = outputFile;
 
70
                        EncodingPassedToPreprocessTemplate = encoding;
 
71
                        
 
72
                        language = PreprocessTemplateLanguageOutParameter;
 
73
                        references = PreprocessTemplateReferencesOutParameter;
 
74
                        
 
75
                        if (ExceptionToThrowWhenPreprocessTemplateCalled != null) {
 
76
                                throw ExceptionToThrowWhenPreprocessTemplateCalled;
 
77
                        }
 
78
                        
 
79
                        return PreprocessTemplateReturnValue;
 
80
                }
 
81
        }
 
82
}