PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/1.31/src/Tests/Platform/ApplicationApiTests.cs

#
C# | 90 lines | 58 code | 12 blank | 20 comment | 0 complexity | acf79f1961719bc2f8e3191e0ea66038 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
  1. /****************************************************************************************************
  2. Copyright (C) 2010 RapidWebDev Organization (http://rapidwebdev.org)
  3. Author: Eunge, Legal Name: Jian Liu, Email: eunge.liu@RapidWebDev.org
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ****************************************************************************************************/
  15. using System;
  16. using System.IO;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Data.Linq;
  20. using System.Text;
  21. using System.Transactions;
  22. using System.Web.UI;
  23. using System.Web.UI.WebControls;
  24. using System.Xml;
  25. using System.Xml.Schema;
  26. using NUnit.Framework;
  27. using BaoJianSoft.Common;
  28. using BaoJianSoft.Platform;
  29. using BaoJianSoft.Platform.Linq;
  30. using BaoJianSoft.RapidWeb;
  31. using BaoJianSoft.RapidWeb.DynamicPages;
  32. using BaoJianSoft.RapidWeb.Controls;
  33. namespace BaoJianSoft.Tests.Platform
  34. {
  35. [TestFixture]
  36. public class ApplicationApiTests
  37. {
  38. [Test, Description("Basic application test")]
  39. public void BasicTest()
  40. {
  41. string applicationName = string.Format("application-{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
  42. string description = applicationName + "-desc";
  43. ApplicationObject applicationObject = new ApplicationObject
  44. {
  45. Name = applicationName,
  46. Description = description
  47. };
  48. IApplicationApi applicationApi = SpringContext.Current.GetObject<IApplicationApi>();
  49. applicationApi.Save(applicationObject);
  50. Assert.IsTrue(applicationApi.Exists(applicationName), "The application should exist");
  51. applicationObject = applicationApi.Get(applicationName);
  52. Assert.AreEqual(applicationName, applicationObject.Name, "The application name should be the same as created.");
  53. Assert.AreEqual(description, applicationObject.Description, "The application description should be the same as created.");
  54. applicationObject = applicationApi.Get(applicationObject.Id);
  55. Assert.AreEqual(applicationName, applicationObject.Name, "The application name should be the same as created.");
  56. Assert.AreEqual(description, applicationObject.Description, "The application description should be the same as created.");
  57. // update application description
  58. description = "modified description";
  59. applicationObject.Description = description;
  60. applicationApi.Save(applicationObject);
  61. // re-check application properties
  62. applicationObject = applicationApi.Get(applicationName);
  63. Assert.AreEqual(applicationName, applicationObject.Name);
  64. applicationObject = applicationApi.Get(applicationObject.Id);
  65. Assert.AreEqual(applicationName, applicationObject.Name);
  66. // update application name
  67. string modifiedApplicationName = string.Format("App-{0}", Guid.NewGuid());
  68. applicationObject.Name = modifiedApplicationName;
  69. applicationApi.Save(applicationObject);
  70. Assert.IsFalse(applicationApi.Exists(applicationName), "The original application name should not exist.");
  71. Assert.IsNull(applicationApi.Get(applicationName), "The original application name should not exist.");
  72. Assert.IsTrue(applicationApi.Exists(modifiedApplicationName), "The modified application name should exist.");
  73. }
  74. }
  75. }