/tags/1.31/src/Tests/Mailing/MessageTagServiceTests.cs
C# | 85 lines | 58 code | 11 blank | 16 comment | 2 complexity | 4964d1301273ae4a1a18784528ebe8aa MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
- /***************************************************************************
- Copyright (C) 2010 RapidWebDev Organization (Author: Eunge, Legal Name: Jian Liu, Email: eunge.liu@gmail.com)
-
- 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 3 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.Collections.Generic;
- using System.Data.Linq;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Transactions;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Xml;
- using System.Xml.Schema;
- using BaoJianSoft.Common;
- using BaoJianSoft.Mailing.Interfaces;
- using BaoJianSoft.Mailing.Objects;
- using BaoJianSoft.Platform;
- using BaoJianSoft.Platform.Linq;
- using BaoJianSoft.Web.Extensions;
- using BaoJianSoft.Web.Extensions.DynamicPages;
- using BaoJianSoft.Web.Extensions.Controls;
- using NUnit.Framework;
-
- namespace BaoJianSoft.Tests.Mailing
- {
- [TestFixture]
- public class MessageTagServiceTests
- {
- [Test, Description("基本的信息标签的CRUD测试")]
- public void BasicCRUDMessageTag()
- {
- IAuthenticationContext authenticationContext = SpringContext.Current.GetObject<IAuthenticationContext>();
- IMessageTagService messageTagService = SpringContext.Current.GetObject<IMessageTagService>();
- MessageTagElement globalMessageTagElement = new MessageTagElement()
- {
- IsGlobal = true, Name = "系统公告"
- };
-
- MessageTagElement localMessageTagElement = new MessageTagElement()
- {
- UserId = authenticationContext.User.UserId, Name = "杭州分司内部"
- };
-
- messageTagService.Create(globalMessageTagElement);
- messageTagService.Create(localMessageTagElement);
-
- var myAvailableTags = messageTagService.FindMyAvailableTags();
- Assert.AreEqual(2, myAvailableTags.Count());
-
- var globalTags = messageTagService.FindGlobalTags();
- Assert.AreEqual(1, globalTags.Count());
-
- globalMessageTagElement.Name = "系统公告X";
- localMessageTagElement.Name = "杭州分司内部X";
-
- messageTagService.Update(globalMessageTagElement);
- messageTagService.Update(localMessageTagElement);
-
- myAvailableTags = messageTagService.FindMyAvailableTags();
- Assert.AreEqual(2, myAvailableTags.Count());
- Assert.IsTrue(myAvailableTags.Where(tag => tag.Name == "系统公告X").Count() > 0);
- Assert.IsTrue(myAvailableTags.Where(tag => tag.Name == "杭州分司内部X").Count() > 0);
-
- messageTagService.Delete(localMessageTagElement.MessageTagId.Value);
- myAvailableTags = messageTagService.FindMyAvailableTags();
- Assert.AreEqual(1, myAvailableTags.Count());
- }
- }
- }
-