From e5cba6bf5031cb9efb7adff3c17d74932bb562ea Mon Sep 17 00:00:00 2001 From: "liuchun_0206@163.com" Date: Sat, 22 Oct 2016 15:48:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EGroupHelperTest.cs=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bootstrap.DataAccessTests.csproj | 1 + Bootstrap.DataAccessTests/GroupHelperTests.cs | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Bootstrap.DataAccessTests/GroupHelperTests.cs diff --git a/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj b/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj index 648748a3..063f696c 100644 --- a/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj +++ b/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj @@ -54,6 +54,7 @@ + diff --git a/Bootstrap.DataAccessTests/GroupHelperTests.cs b/Bootstrap.DataAccessTests/GroupHelperTests.cs new file mode 100644 index 00000000..3afec8b6 --- /dev/null +++ b/Bootstrap.DataAccessTests/GroupHelperTests.cs @@ -0,0 +1,53 @@ +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Bootstrap.DataAccess.Tests +{ + [TestClass] + public class GroupHelperTests + { + [TestMethod] + public void RetrieveGroupsTest() + { + var result = GroupHelper.RetrieveGroups("1"); + Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的GroupHelper.RetrieveGroups方法调用失败,请检查数据库连接或者数据库SQL语句"); + result = GroupHelper.RetrieveGroups(); + Assert.IsTrue(result.Count() >= 0, "不带参数的GroupHelper.RetrieveGroups方法调用失败,请检查数据库连接或者数据库SQL语句"); + } + + [TestMethod] + public void SaveGroupTest() + { + Group p = new Group(); + p.GroupName = "测试群组2"; + p.Description = "测试群组2"; + + var result = GroupHelper.SaveGroup(p); + Assert.IsTrue(result, "增加用户出错"); + + p.ID = 4; + p.GroupName = "测试群组22"; + p.Description = "测试群组22"; + result = GroupHelper.SaveGroup(p); + Assert.IsTrue(result, "更新用户出错"); + + } + + [TestMethod] + public void DeleteGroupTest() + { + string p = "2"; + try + { + GroupHelper.DeleteGroup(p); + Assert.IsTrue(true); + } + catch + { + Assert.IsTrue(false, "删除用户出错"); + } + } + + + } +}