1
using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
2 using SMSApi
.Api
.Response
;
4 namespace smsapiTests
.Contacts
7 public class GroupsTest
: ContactsTestBase
14 Groups groups
= _factory
.ListGroups().Execute();
15 foreach (Group
group in groups
.Collection
)
17 _factory
.DeleteGroup(group.Id
).Execute();
22 public void CreateGroup()
24 Group
group = _factory
.CreateGroup().SetName("exampleGroup1").Execute();
26 Assert
.AreEqual("exampleGroup1", group.Name
);
27 Assert
.IsNotNull(group.Id
);
31 public void CreateGroupPermission()
33 GroupPermission groupPermission
= _factory
.CreateGroupPermission(_group
.Id
).
34 SetUsername(_username
).
40 Assert
.AreEqual(_username
, groupPermission
.Username
);
44 public void EditGroup()
46 Group response
= _factory
.EditGroup(_group
.Id
).SetName("GroupY").Execute();
48 Assert
.AreEqual(_group
.Id
, response
.Id
);
49 Assert
.AreNotEqual(_group
.Name
, response
.Name
);
50 Assert
.AreEqual("GroupY", response
.Name
);
51 Assert
.AreEqual(_group
.Description
, response
.Description
);
53 if (string.IsNullOrEmpty(_group
.Idx
))
55 Assert
.IsTrue(string.IsNullOrEmpty(response
.Idx
));
59 Assert
.AreEqual(_group
.Idx
, response
.Idx
);
64 public void EditGroupPermission()
66 GroupPermission groupPermission
= _factory
.EditGroupPermission(_group
.Id
, _username
).
72 Assert
.IsTrue(groupPermission
.Read
);
73 Assert
.IsTrue(groupPermission
.Write
);
74 Assert
.IsTrue(groupPermission
.Send
);
78 public void GetGroup()
80 Group response
= _factory
.GetGroup(_group
.Id
).Execute();
82 Assert
.AreEqual(_group
.Id
, response
.Id
);
83 Assert
.AreEqual(_group
.Name
, response
.Name
);
84 Assert
.AreEqual(_group
.Description
, response
.Description
);
86 if (string.IsNullOrEmpty(_group
.Idx
))
88 Assert
.IsTrue(string.IsNullOrEmpty(response
.Idx
));
92 Assert
.AreEqual(_group
.Idx
, response
.Idx
);
97 public void ListGroupPermissions()
99 _factory
.ListGroupPermissions(_group
.Id
).Execute();
103 public void ListGroups()
105 _factory
.ListGroups().Execute();
109 public void ListGroupsWithFilterByName()
111 Groups listResponse
= _factory
.ListGroups().SetName("exampleGroup").Execute();
113 Assert
.AreEqual(1, listResponse
.Collection
.Count
);
117 public void ListWithFilterByName_ShouldNotFound()
119 Groups listResponse
= _factory
.ListGroups().SetName("missingGroup").Execute();
121 Assert
.AreEqual(0, listResponse
.Collection
.Count
);
125 public override void SetUp()
129 _group
= _factory
.CreateGroup().SetName("exampleGroup").Execute();