public GetRolesResponse GetRolesByCriteria(GetRolesRequest request) { GetRolesResponse response = new GetRolesResponse(); SecurityBusinessComponent bc = DependencyInjectionHelper.GetSecurityBusinessComponent(); IQueryable<Role> roles = bc.GetRolesByCriteria(request.SearchType, request.Rolename); response.Roles = SecurityAdapter.RolesToDTOs(roles); return response; }
public void TestGetRoles() { int roleId = 1; GetRolesResponse response = new GetRolesResponse(); response.Roles.Add(new RoleDTO() { Id = roleId, RoleName = "FakeRole" }); Expect.Once.On(service).Method("GetRolesByCriteria").Will(Return.Value(response)); IList<RoleDTO> roles = serviceFacade.GetRolesByName("FakeRole"); Assert.AreEqual(1, roles.Count); Assert.AreEqual(roles.First().Id, roleId); Expect.Once.On(service).Method("GetRolesByCriteria").Will(Return.Value(response)); roles = serviceFacade.GetAllRoles(); Assert.AreEqual(1, roles.Count); Assert.AreEqual(roles.First().Id, roleId); }