Beispiel #1
0
        public void CanExecute_DenyRoleSatisfied_ReturnsTrue()
        {
            // Arrange
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("SomeUser"), new string[] {});
            var command = new SecureRelayCommand(DenyRoleMethod, x => true);

            // Act
            var result = command.CanExecute(null);

            // Assert
            Assert.IsTrue(result);
        }
Beispiel #2
0
        public void CanExecute_IsAuthorized_ReturnsCanExecuteFunc()
        {
            // Arrange
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("SomeUser"), new string[] { "Role1" });
            var command = new SecureRelayCommand(AllowRoleMethod, x => false);

            // Act
            var result = command.CanExecute(null);

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #3
0
        public void Execute_IsAuthorized_MethodIsExecuted()
        {
            // Arrange
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("SomeUser"), new string[] { "Role1" });
            var command = new SecureRelayCommand(AllowRoleMethod, x => true);

            // Act
            command.Execute(null);

            // Assert
            Assert.AreEqual("AllowRoleMethod", LastMethodExeuted);
        }
Beispiel #4
0
 public MainViewModel()
 {
     SecureCommand = new SecureRelayCommand(MySecureMethod, x => true);
 }