1 using System; 2 using NUnit.Framework; 3 using Premake.Tests.Framework; 4 5 namespace Premake.Tests.Vs2003.Cs 6 { 7 [TestFixture] 8 public class Test_BuildActions 9 { 10 Script _script; 11 Project _expects; 12 Parser _parser; 13 14 #region Setup and Teardown 15 [SetUp] Test_Setup()16 public void Test_Setup() 17 { 18 _script = Script.MakeBasic("exe", "c#"); 19 20 _expects = new Project(); 21 _expects.Package.Add(1); 22 _expects.Package[0].Config.Add(2); 23 24 _parser = new Vs2003Parser(); 25 } 26 Run()27 public void Run() 28 { 29 TestEnvironment.Run(_script, _parser, _expects, null); 30 } 31 #endregion 32 33 [Test] Test_DefaultCodeAction()34 public void Test_DefaultCodeAction() 35 { 36 _script.Replace("'somefile.txt'", "'file0.cs'"); 37 _expects.Package[0].File.Add("file0.cs", "code", "Compile"); 38 Run(); 39 } 40 41 [Test] Test_CodeAsContent()42 public void Test_CodeAsContent() 43 { 44 _script.Replace("'somefile.txt'", "'file0.cs','file1.cs'"); 45 _script.Append("package.config['file1.cs'].buildaction = 'Content'"); 46 _expects.Package[0].File.Add("file0.cs", "code", "Compile"); 47 _expects.Package[0].File.Add("file1.cs", "Content"); 48 Run(); 49 } 50 51 [Test] Test_AspxCodeAction()52 public void Test_AspxCodeAction() 53 { 54 _script.Replace("'somefile.txt'", "'file0.aspx.cs'"); 55 _expects.Package[0].File.Add("file0.aspx.cs", "aspxcodebehind", "Compile", "file0.aspx"); 56 Run(); 57 } 58 59 [Test] Test_AspxAction()60 public void Test_AspxAction() 61 { 62 _script.Replace("'somefile.txt'", "'file0.aspx'"); 63 _expects.Package[0].File.Add("file0.aspx", "form", "Content"); 64 Run(); 65 } 66 67 [Test] Test_AsaxAction()68 public void Test_AsaxAction() 69 { 70 _script.Replace("'somefile.txt'", "'file0.asax'"); 71 _expects.Package[0].File.Add("file0.asax", "component", "Content"); 72 Run(); 73 } 74 75 [Test] Test_ResxAction()76 public void Test_ResxAction() 77 { 78 _script.Replace("'somefile.txt'", "'file0.resx'"); 79 _expects.Package[0].File.Add("file0.resx", null, "EmbeddedResource"); 80 Run(); 81 } 82 83 84 [Test] Test_ResxWithDependencyAction()85 public void Test_ResxWithDependencyAction() 86 { 87 _script.Replace("'somefile.txt'", "'file0.resx','file0.cs'"); 88 _expects.Package[0].File.Add("file0.resx", null, "EmbeddedResource", "file0.cs"); 89 _expects.Package[0].File.Add("file0.cs"); 90 Run(); 91 } 92 93 [Test] Test_DefaultBuildAction()94 public void Test_DefaultBuildAction() 95 { 96 _expects.Package[0].File.Add("somefile.txt", "None"); 97 Run(); 98 } 99 100 [Test] Test_CustomBuildAction()101 public void Test_CustomBuildAction() 102 { 103 _script.Append("package.config['somefile.txt'].buildaction = 'EmbeddedResource'"); 104 _expects.Package[0].File.Add("somefile.txt", "EmbeddedResource"); 105 Run(); 106 } 107 108 } 109 } 110