CassiniDevNUnitFixture.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using NUnit.Framework;
  7. namespace CassiniDev.NUnitFixtures.Tests
  8. {
  9. /// <summary>
  10. /// Note: this fixture leverages the in-process CassiniDev server. If you have restrictions or experience
  11. /// issues with the in-process server, simply reference CassiniDev-console and use CassiniDevServerOP.
  12. /// API and usage is same.
  13. /// </summary>
  14. [TestFixture]
  15. public class CassiniDevNUnitFixture : CassiniDevServer
  16. {
  17. [TestFixtureSetUp]
  18. public void TestFixtureSetUp()
  19. {
  20. // just need to back out of the bin dir
  21. const string applicationPath = @"..\";
  22. // Will start specified application as "localhost" on loopback and first available port in the range 8000-10000 with vpath "/"
  23. StartServer(applicationPath);
  24. // if you would like to exercise more control simply use any of the available overloads
  25. }
  26. //// this is left over from out-of-process fixture. I really don't think it is
  27. //// necessary in-proc, but a zombie thread might cause trouble. salt to taste
  28. //[TestFixtureTearDown]
  29. //public void TestFixtureTearDown()
  30. //{
  31. // StopServer();
  32. //}
  33. [Test]
  34. public void Test()
  35. {
  36. // normalize URL provides a fully qualified URL rooted on the currently running server's hostname and port
  37. string url = NormalizeUrl("Default.aspx");
  38. WebClient wc = new WebClient();
  39. string actual = wc.DownloadString(url);
  40. Assert.IsTrue(actual.Contains("this is default.aspx"));
  41. // for a web testing utility library that simplifies endpoint testing see the Salient.Web namespace in http://salient.codeplex.com
  42. }
  43. }
  44. }