public void WhenSelectedPermissionIsSet_SecurityFieldsAreUpdated()
        {
            // Arrange.
            const int roleId = 147;
            const int businessUnitId = 111;
            var permission = new ProcessSecurityConfigurationEditMock(roleId, businessUnitId, true, false);

            // Act.
            this._target.SelectedPermission = new ProcessSecurityViewModel.PersmissionGroupViewModel() {Model = permission};

            // Assert.
            Assert.AreEqual(roleId, this._target.SelectedRoleId);
            Assert.AreEqual(businessUnitId, this._target.SelectedBusinessUnitId);
        }
        public void PermissionRemoveCommandTests()
        {
            // Arrange.
            const int roleId = 147;
            const int businessUnitId = 111;
            var permission = new ProcessSecurityConfigurationEditMock(roleId, businessUnitId, true, false);
            var model = new ProcessEditMock(1);

            var processEditExtensionsMock = Mock.Create<ProcessEditExtensions>();
            model.ProcessEditExtensions = processEditExtensionsMock;

            model.SecurityConfigurationList.Add(permission);
            this._target.Model = model;
            this._target.OnRefreshed();

            // Act.
            this._target.SelectedPermission = null;

            // Assert.
            Assert.IsFalse(this._target.PermissionRemoveCommand.CanExecute(null));

            // Act.
            this._target.SelectedPermission = new ProcessSecurityViewModel.PersmissionGroupViewModel { Model = permission };

            // Assert.
            Assert.IsTrue(this._target.PermissionRemoveCommand.CanExecute(null));

            // Arrange.
            var propertiesChanged = new List<string>();

            this._target.PropertyChanged += (o, e) => propertiesChanged.Add(e.PropertyName);

            // Act.
            this._target.PermissionRemoveCommand.Execute(null);

            // Assert.
            Assert.IsFalse(this._target.Model.SecurityConfigurationList.Contains(permission));
            Assert.IsNull(this._target.SelectedPermission);
        }
        public void SelectedPermission_ChangeNotifications()
        {
            // Arrange.
            const int roleId = 147;
            const int businessUnitId = 111;
            var propertiesChanged = new List<string>();
            var permission = new ProcessSecurityConfigurationEditMock(roleId, businessUnitId, true, false);
            var permissionRemoveCommandFired = false;

            this._target.PropertyChanged += (o, e) => propertiesChanged.Add(e.PropertyName);
            this._target.PermissionRemoveCommand.CanExecuteChanged += (o, e) => permissionRemoveCommandFired = true;

            // Act.
            this._target.SelectedPermission = new ProcessSecurityViewModel.PersmissionGroupViewModel() {Model = permission};

            // Assert.
            Assert.IsTrue(propertiesChanged.Contains("SelectedPermission"));
            Assert.IsTrue(permissionRemoveCommandFired);
        }