d0cd9642a194b2f7c7c0b4737ce4dc12fc7b5271.svn-base 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using iBemsDataService.Controllers;
  4. using System.Net.Http;
  5. using System.Web.Http;
  6. using System.Web.Http.Routing;
  7. using System.Diagnostics;
  8. namespace iBemsDataService.Tests
  9. {
  10. [TestClass]
  11. public class TestBemsFormulaController
  12. {
  13. [TestMethod]
  14. public void TestFormulaCalculation()
  15. {
  16. try
  17. {
  18. var controller = new BemsFormulaController();
  19. controller.Request = new HttpRequestMessage
  20. {
  21. //RequestUri = new Uri( "http://localhost:3403/api/BemsFormula/Calculation" +
  22. // "?SiteId=1&FacilityTypeId=1&FacilityCode=1&FormulaId=1" +
  23. // "&TimeIntervalType=1&StartDate=2014-11-04 00:00&EndDate=2014-11-05 11:45" ) ,
  24. //RequestUri = new Uri( "http://localhost:3403/api/BemsFormula/Calculation?&FacilityTypeId=26&FacilityCode=3&FormulaId=1&TimeIntervalType=4&StartDate=2014-01-01%2000:00:00&EndDate=2014-12-16%2018:57:37&SiteId=1" ) ,
  25. // RequestUri = new Uri( "http://localhost:3403/api/BemsFormula/Calculation?&FacilityTypeId=24&FacilityCode=1&FormulaId=1&TimeIntervalType=2&StartDate=2014-12-21%2000:00:00&EndDate=2014-12-21%2023:59:59&SiteId=1" ) ,
  26. RequestUri = new Uri( "http://localhost:3403/api/BemsFormula/Calculation?&FacilityTypeId=24&FacilityCode=1&FormulaId=1&TimeIntervalType=2&StartDate=2014-12-15%2000:00:00&EndDate=2014-12-15%2023:59:59&SiteId=1" ) ,
  27. };
  28. controller.Configuration = new HttpConfiguration();
  29. var list = controller.GetBemsFormula();
  30. foreach( var v in list )
  31. {
  32. Trace.WriteLine( string.Format( "{0} {1} - {2}" ,
  33. v.DateTime.ToShortDateString() ,
  34. v.DateTime.ToShortTimeString() ,
  35. v.Value ));
  36. }
  37. Assert.IsTrue( true );
  38. }
  39. catch( Exception e )
  40. {
  41. Trace.WriteLine( e.Message );
  42. throw e;
  43. }
  44. }
  45. }
  46. }