Beispiel #1
0
        public void VerificationException_Construction_2()
        {
            const string          expected  = "Key";
            VerificationException exception = new VerificationException(expected);

            Assert.AreEqual(expected, exception.Message);
        }
 public static void CreateExceptionWithVerificationErrors()
 {
     var errors = new List<VerificationError>();
     errors.Add(VerificationError.Create(
         @"[IL]: Error: [C:\Proxy.dll : AType::HookByRefValueTypeProxy][offset 0x00000025][found Int32] Expected an ObjRef on the stack."));
     var exception = new VerificationException(errors.AsReadOnly());
     Assert.Equal(1, exception.Errors.Count);
 }
        public void IsVerificationExceptionTest()
        {
            //Arrange
            VerificationException exception = new VerificationException(new EntityException(
                                                                            "This is a test message", ErrorCode.INVALID_FIELDS, RestStatusCodes.REST_CLIENT_ERROR_UNPROCESSABLE_ENTITY, 101));

            //Assert
            Assert.IsTrue(VerificationException.IsVerificationException(exception));
        }
        public void VerificationExceptionTest2()
        {
            //Arrange
            EntityException entityexception = new EntityException("This is a test exception", ErrorCode.INVALID_FIELDS, 200, 999);

            //Act
            VerificationException verificationexception = new VerificationException(entityexception);

            //Assert
            Assert.AreEqual(verificationexception.Message, "Verification of token failed");
        }
        public void VerificationExceptionTest1()
        {
            //Arrange
            EntityException entityexception = new EntityException("This is a test exception", ErrorCode.INVALID_FIELDS, 200, 101);

            //Act
            VerificationException verificaitonexception = new VerificationException(entityexception);

            //Assert
            Assert.AreEqual(verificaitonexception.Message, "The verification was already completed");
        }
Beispiel #6
0
        public void VerificationException_Construction_3()
        {
            Exception             innerException = new Exception("Message");
            const string          expected       = "Key";
            VerificationException exception      = new VerificationException
                                                   (
                expected,
                innerException
                                                   );

            Assert.AreEqual(expected, exception.Message);
            Assert.AreEqual(innerException, exception.InnerException);
        }
 private protected static bool IsSecurityConflict(VerificationException ve, string accessorPrefix = null)
 {
     try
     {
         var    stackTrace = new StackTrace(ve);
         string methodName = stackTrace.FrameCount > 0 ? stackTrace.GetFrame(0).GetMethod().Name : null;
         if (methodName == null)
         {
             return(false);
         }
         return(accessorPrefix == null?methodName.ContainsAny(methodInvokerPrefix, ctorInvokerPrefix) : methodName.StartsWith(accessorPrefix, StringComparison.Ordinal));
     }
     catch (Exception e) when(!e.IsCritical())
     {
         // if we cannot obtain the stack trace we assume the VerificationException is due to the used security settings
         return(true);
     }
 }
Beispiel #8
0
    public static void CheckVerificationExceptionMessage(uint ResourceID, VerificationException e, string type, string methodName, string violatingType)
    {
        // "Method %1.%2: type argument '%3' violates the constraint of type parameter '%4'."
        bool found1 = e.ToString().IndexOf(type + "." + methodName) >= 0;
        bool found2 = e.ToString().IndexOf(violatingType) >= 0;
        bool found3 = e.ToString().IndexOf("T") >= 0;

        if (!found1 || !found2 || !found3)
        {
            Console.WriteLine(" : Exception message is incorrect");
            Console.WriteLine("Expected: " + "Method " + type + "." + methodName + ": type argument '" + violatingType + "' violates the constraint of type parameter 'T'");
            Console.WriteLine("Actual: " + e.Message.ToString());
            pass = false;
        }
        else
        {
            Console.WriteLine(" : Caught expected exception");
        }
    }
Beispiel #9
0
        public void VerificationException_Construction_1()
        {
            VerificationException exception = new VerificationException();

            Assert.IsNotNull(exception.Message);
        }