BuildManagerCacheFiles.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. // Authors:
  3. // Marek Habersack ([email protected])
  4. //
  5. // (C) 2010 Novell, Inc http://novell.com/
  6. //
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Configuration;
  30. using System.Configuration.Provider;
  31. using System.IO;
  32. using System.Web;
  33. using System.Web.Hosting;
  34. using StandAloneRunnerSupport;
  35. using StandAloneTests;
  36. using NUnit.Framework;
  37. namespace StandAloneTests.BuildManagerCacheFiles
  38. {
  39. [TestCase ("BuildManagerCacheFiles 01", "Tests for BuildManager.{Create,Read}CacheFile")]
  40. public sealed class BuildManagerCacheFiles_01 : ITestCase
  41. {
  42. static string[] expectedMessages = {
  43. "create[1]: codeGen",
  44. "create[1]: fileStream",
  45. "create[1]: can read",
  46. "create[1]: can write",
  47. "create[1]: pathSubdirOfCodeGen",
  48. "create[1]: our file name",
  49. "read[1]: codeGen",
  50. "read[1]: fileStream",
  51. "read[1]: can read",
  52. "read[1]: cannot write",
  53. "read[1]: pathSubdirOfCodeGen",
  54. "read[1]: our file name",
  55. "read[1]: contents ok",
  56. "create[2]: codeGen",
  57. // .NET exception:
  58. //
  59. // System.ArgumentException: Value does not fall within the expected range.
  60. // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
  61. // at System.Web.Compilation.BuildManager.CreateCachedFile(String fileName)
  62. // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 56)
  63. "create[2]: error write (System.ArgumentException)",
  64. "read[2]: codeGen",
  65. // .NET exception:
  66. //
  67. // System.ArgumentException: Value does not fall within the expected range.
  68. // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
  69. // at System.Web.Compilation.BuildManager.ReadCachedFile(String fileName)
  70. // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 86)
  71. "read[2]: error read (System.ArgumentException)",
  72. "read[3]: codeGen",
  73. "read[3]: stream is null",
  74. "create[4]: codeGen",
  75. // .NET exception
  76. // System.ArgumentNullException: Value cannot be null.
  77. // Parameter name: path2
  78. // at System.IO.Path.Combine(String path1, String path2)
  79. // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
  80. // at System.Web.Compilation.BuildManager.CreateCachedFile(String fileName)
  81. // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 61)
  82. "create[4]: error write (System.ArgumentNullException)",
  83. "read[4]: codeGen",
  84. // .NET exception
  85. // System.ArgumentNullException: Value cannot be null.
  86. // Parameter name: path2
  87. // at System.IO.Path.Combine(String path1, String path2)
  88. // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
  89. // at System.Web.Compilation.BuildManager.ReadCachedFile(String fileName)
  90. // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 91)
  91. "read[4]: error read (System.ArgumentNullException)",
  92. "create[5]: codeGen",
  93. // .NET exception
  94. // System.ArgumentException: Value does not fall within the expected range.
  95. // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
  96. // at System.Web.Compilation.BuildManager.CreateCachedFile(String fileName)
  97. // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 61)
  98. "create[5]: error write (System.ArgumentException)",
  99. "read[5]: codeGen",
  100. // .NET exception
  101. // System.ArgumentException: Value does not fall within the expected range.
  102. // at System.Web.Compilation.BuildManager.GetUserCacheFilePath(String fileName)
  103. // at System.Web.Compilation.BuildManager.ReadCachedFile(String fileName)
  104. // at _Default.RunTest(String fileName, String logTag, List`1 messages, Boolean noCreate) in c:\Users\grendel\Documents\Visual Studio 2010\Websites\BuildManager4.0\Default.aspx.cs:line 91)
  105. "read[5]: error read (System.ArgumentException)",
  106. };
  107. public string PhysicalPath {
  108. get {
  109. return Path.Combine (
  110. Consts.BasePhysicalDir,
  111. "BuildManagerCacheFiles"
  112. );
  113. }
  114. }
  115. public string VirtualPath {
  116. get { return "/"; }
  117. }
  118. public bool SetUp (List <TestRunItem> runItems)
  119. {
  120. runItems.Add (new TestRunItem ("/Default.aspx", Default_Aspx));
  121. return true;
  122. }
  123. void Default_Aspx (string result, TestRunItem runItem)
  124. {
  125. var messages = runItem.TestRunData as List <string>;
  126. Assert.IsNotNull (messages, "#A1");
  127. int len = messages.Count;
  128. int i = 0;
  129. for (; i < len; i++)
  130. Assert.AreEqual (expectedMessages [i], messages [i], "#A2-" + i.ToString ());
  131. if (i != len)
  132. Assert.Fail ("Expected {0} messages, found {1}", i, len);
  133. }
  134. }
  135. }