~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/IOErrorTestFixture.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.Reflection;
 
6
using System.Reflection.Emit;
 
7
using IronPython.Runtime;
 
8
using IronPython.Runtime.Operations;
 
9
using ICSharpCode.Python.Build.Tasks;
 
10
using Microsoft.Build.Framework;
 
11
using Microsoft.Build.Utilities;
 
12
using Microsoft.Scripting;
 
13
using Microsoft.Scripting.Hosting;
 
14
using Microsoft.Scripting.Runtime;
 
15
using NUnit.Framework;
 
16
 
 
17
namespace Python.Build.Tasks.Tests
 
18
{
 
19
        /// <summary>
 
20
        /// Tests that an IOException is caught and logged.
 
21
        /// </summary>
 
22
        [TestFixture]
 
23
        public class IOErrorTestFixture
 
24
        {
 
25
                MockPythonCompiler mockCompiler;
 
26
                DummyPythonCompilerTask compiler;
 
27
                bool success;
 
28
                
 
29
                [SetUp]
 
30
                public void Init()
 
31
                {
 
32
                        mockCompiler = new MockPythonCompiler();
 
33
                        compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
 
34
                        compiler.TargetType = "Exe";
 
35
                        compiler.OutputAssembly = "test.exe";
 
36
                        
 
37
                        TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
 
38
                        compiler.Sources = new ITaskItem[] {sourceFile};
 
39
                        
 
40
                        mockCompiler.ThrowExceptionAtCompile = PythonOps.IOError("Could not find main file test.py");
 
41
                        
 
42
                        success = compiler.Execute();
 
43
                }
 
44
                
 
45
                [Test]
 
46
                public void ExecuteFailed()
 
47
                {
 
48
                        Assert.IsFalse(success);
 
49
                }
 
50
                
 
51
                [Test]
 
52
                public void IsExceptionMessageLogged()
 
53
                {
 
54
                        Assert.AreEqual("Could not find main file test.py", compiler.LoggedErrorMessage);
 
55
                }
 
56
        }
 
57
}