private void LoadData(Guid?userGroupId = null)
        {
            BindingModel.Clear();

            var requestDispatcher = RequestDispatcherFactory.CreateAsyncRequestDispatcher();

            if (userGroupId.HasValue)
            {
                requestDispatcher.Add(new CheckPermissionsRequest {
                    PermissionsToCheck = new[] { Permissions.DeleteUserGroup, Permissions.EditUserGroup }
                });
                requestDispatcher.Add(new GetUserGroupRequest {
                    UserGroupId = userGroupId.Value
                });
            }
            requestDispatcher.Add(new GetSuitableParentUserGroupsRequest {
                UserGroupId = userGroupId
            });
            requestDispatcher.ProcessRequests(ResponsesReceived, PublishRemoteException);
        }
Ejemplo n.º 2
0
        public void Clear_SetsEverythingBackToItsInitialState()
        {
            var suitableParentGroups = new[] { new UserGroupDto {
                                                   Id = Guid.NewGuid(), Name = "some parent"
                                               } };
            var userGroup = new UserGroupDto {
                Id = Guid.NewGuid(), Name = "some name", ParentId = suitableParentGroups[0].Id
            };

            BindingModel.Populate(suitableParentGroups, userGroup);

            BindingModel.Clear();

            Assert.IsNull(BindingModel.Id);
            Assert.IsNull(BindingModel.Name);

            Assert.AreEqual(1, BindingModel.SuitableParentUserGroups.Count);
            Assert.AreEqual(Guid.Empty, BindingModel.SuitableParentUserGroups[0].Id);
            Assert.AreEqual("None", BindingModel.SuitableParentUserGroups[0].Name);
        }