/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
- /****************************************************************************************************
- Copyright (C) 2010 RapidWebDev Organization (http://rapidwebdev.org)
- Author: Eunge, Legal Name: Jian Liu, Email: eunge.liu@RapidWebDev.org
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- ****************************************************************************************************/
-
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data.Linq;
- using System.Text;
- using System.Transactions;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Xml;
- using System.Xml.Schema;
- using NUnit.Framework;
- using BaoJianSoft.Common;
- using BaoJianSoft.Platform;
- using BaoJianSoft.Platform.Linq;
- using BaoJianSoft.RapidWeb;
- using BaoJianSoft.RapidWeb.DynamicPages;
- using BaoJianSoft.RapidWeb.Controls;
-
- namespace BaoJianSoft.Tests.Platform
- {
- [TestFixture]
- public class ApplicationApiTests
- {
- [Test, Description("Basic application test")]
- public void BasicTest()
- {
- string applicationName = string.Format("application-{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
- string description = applicationName + "-desc";
- ApplicationObject applicationObject = new ApplicationObject
- {
- Name = applicationName,
- Description = description
- };
-
- IApplicationApi applicationApi = SpringContext.Current.GetObject<IApplicationApi>();
- applicationApi.Save(applicationObject);
-
- Assert.IsTrue(applicationApi.Exists(applicationName), "The application should exist");
-
- applicationObject = applicationApi.Get(applicationName);
- Assert.AreEqual(applicationName, applicationObject.Name, "The application name should be the same as created.");
- Assert.AreEqual(description, applicationObject.Description, "The application description should be the same as created.");
-
- applicationObject = applicationApi.Get(applicationObject.Id);
- Assert.AreEqual(applicationName, applicationObject.Name, "The application name should be the same as created.");
- Assert.AreEqual(description, applicationObject.Description, "The application description should be the same as created.");
-
- // update application description
- description = "modified description";
- applicationObject.Description = description;
- applicationApi.Save(applicationObject);
-
- // re-check application properties
- applicationObject = applicationApi.Get(applicationName);
- Assert.AreEqual(applicationName, applicationObject.Name);
-
- applicationObject = applicationApi.Get(applicationObject.Id);
- Assert.AreEqual(applicationName, applicationObject.Name);
-
- // update application name
- string modifiedApplicationName = string.Format("App-{0}", Guid.NewGuid());
- applicationObject.Name = modifiedApplicationName;
- applicationApi.Save(applicationObject);
-
- Assert.IsFalse(applicationApi.Exists(applicationName), "The original application name should not exist.");
- Assert.IsNull(applicationApi.Get(applicationName), "The original application name should not exist.");
- Assert.IsTrue(applicationApi.Exists(modifiedApplicationName), "The modified application name should exist.");
- }
- }
- }
-