PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. /***************************************************************************
  2. Copyright (C) 2010 RapidWebDev Organization (Author: Eunge, Legal Name: Jian Liu, Email: eunge.liu@gmail.com)
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ***************************************************************************/
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Data.Linq;
  17. using System.IO;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Transactions;
  21. using System.Web.UI;
  22. using System.Web.UI.WebControls;
  23. using System.Xml;
  24. using System.Xml.Schema;
  25. using BaoJianSoft.Common;
  26. using BaoJianSoft.Mailing.Interfaces;
  27. using BaoJianSoft.Mailing.Objects;
  28. using BaoJianSoft.Platform;
  29. using BaoJianSoft.Platform.Linq;
  30. using BaoJianSoft.Web.Extensions;
  31. using BaoJianSoft.Web.Extensions.DynamicPages;
  32. using BaoJianSoft.Web.Extensions.Controls;
  33. using NUnit.Framework;
  34. namespace BaoJianSoft.Tests.Mailing
  35. {
  36. [TestFixture]
  37. public class MessageTagServiceTests
  38. {
  39. [Test, Description("基本的信息标签的CRUD测试")]
  40. public void BasicCRUDMessageTag()
  41. {
  42. IAuthenticationContext authenticationContext = SpringContext.Current.GetObject<IAuthenticationContext>();
  43. IMessageTagService messageTagService = SpringContext.Current.GetObject<IMessageTagService>();
  44. MessageTagElement globalMessageTagElement = new MessageTagElement()
  45. {
  46. IsGlobal = true, Name = "系统公告"
  47. };
  48. MessageTagElement localMessageTagElement = new MessageTagElement()
  49. {
  50. UserId = authenticationContext.User.UserId, Name = "杭州分司内部"
  51. };
  52. messageTagService.Create(globalMessageTagElement);
  53. messageTagService.Create(localMessageTagElement);
  54. var myAvailableTags = messageTagService.FindMyAvailableTags();
  55. Assert.AreEqual(2, myAvailableTags.Count());
  56. var globalTags = messageTagService.FindGlobalTags();
  57. Assert.AreEqual(1, globalTags.Count());
  58. globalMessageTagElement.Name = "系统公告X";
  59. localMessageTagElement.Name = "杭州分司内部X";
  60. messageTagService.Update(globalMessageTagElement);
  61. messageTagService.Update(localMessageTagElement);
  62. myAvailableTags = messageTagService.FindMyAvailableTags();
  63. Assert.AreEqual(2, myAvailableTags.Count());
  64. Assert.IsTrue(myAvailableTags.Where(tag => tag.Name == "系统公告X").Count() > 0);
  65. Assert.IsTrue(myAvailableTags.Where(tag => tag.Name == "杭州分司内部X").Count() > 0);
  66. messageTagService.Delete(localMessageTagElement.MessageTagId.Value);
  67. myAvailableTags = messageTagService.FindMyAvailableTags();
  68. Assert.AreEqual(1, myAvailableTags.Count());
  69. }
  70. }
  71. }