// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: the parameter string is null."); try { string expectValue = null; ArgumentException dpoExpection = new ArgumentException(); MethodAccessException myException = new MethodAccessException(expectValue, dpoExpection); if (myException == null) { TestLibrary.TestFramework.LogError("002.1", "MethodAccessException instance can not create correctly."); retVal = false; } if (myException.Message == expectValue) { TestLibrary.TestFramework.LogError("002.2", "the Message should return the default value."); retVal = false; } if (!(myException.InnerException is ArgumentException)) { TestLibrary.TestFramework.LogError("002.3", "the InnerException should return MethodAccessException."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); retVal = false; } return(retVal); }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: the parameter string is null."); try { string expectValue = null; MethodAccessException myException = new MethodAccessException(expectValue); if (myException == null) { TestLibrary.TestFramework.LogError("002.1", "MethodAccessException instance can not create correctly."); retVal = false; } if (myException.Message == expectValue) { TestLibrary.TestFramework.LogError("002.2", "the Message should return the default value."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); retVal = false; } return retVal; }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new instance of MethodAccessException."); try { string expectValue = "HELLO"; ArgumentException notFoundException = new ArgumentException(); MethodAccessException myException = new MethodAccessException(expectValue, notFoundException); if (myException == null) { TestLibrary.TestFramework.LogError("001.1", "MethodAccessException instance can not create correctly."); retVal = false; } if (myException.Message != expectValue) { TestLibrary.TestFramework.LogError("001.2", "the Message should return " + expectValue); retVal = false; } if (!(myException.InnerException is ArgumentException)) { TestLibrary.TestFramework.LogError("001.3", "the InnerException should return ArgumentException."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); retVal = false; } return(retVal); }
public static void MethodAccessException_Ctor2() { MethodAccessException i = new MethodAccessException("Created MethodAccessException"); Assert.Equal("Created MethodAccessException", i.Message); Assert.Equal(COR_E_METHODACCESS, i.HResult); }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new instance of MethodAccessException."); try { string expectValue = "HELLO"; MethodAccessException myException = new MethodAccessException(expectValue); if (myException == null) { TestLibrary.TestFramework.LogError("001.1", "MethodAccessException instance can not create correctly."); retVal = false; } if (myException.Message != expectValue) { TestLibrary.TestFramework.LogError("001.2", "the Message should return " + expectValue); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); retVal = false; } return retVal; }
public static void Ctor_Empty() { var exception = new MethodAccessException(); Assert.NotEmpty(exception.Message); Assert.Equal(COR_E_METHODACCESS, exception.HResult); }
public static void MethodAccessException_Ctor1() { MethodAccessException i = new MethodAccessException(); //Assert.Equal("Attempted to access a missing method.", i.Message, "TestCtor1_001 failed"); Assert.Equal(COR_E_METHODACCESS, i.HResult); }
TryToInitializeTypeInstance(out T instance) { instance = default(T); Type type = typeof(T); if (HasPublicContructors(type)) { MethodAccessException exception = GetPublicConstructorsFoundError(type); return(status : false, exception : exception); } MethodInfo parametrizedTypeInitializator = type.GetMethod("InitializeInstance", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Static); if (parametrizedTypeInitializator == null) { MissingMethodException exception = GetMissingMethodError(type); return(status : false, exception : exception); } try { instance = (T)parametrizedTypeInitializator.Invoke(null, new object[] { }); return(status : true, exception : null); } catch (Exception e) { return(status : false, exception : e); } }
public static void Ctor_String() { string message = "Created MethodAccessException"; var exception = new MethodAccessException(message); Assert.Equal(message, exception.Message); Assert.Equal(COR_E_METHODACCESS, exception.HResult); }
public static void MethodAccessException_Ctor3() { Exception ex = new Exception("Created inner exception"); MethodAccessException i = new MethodAccessException("Created MethodAccessException", ex); Assert.Equal("Created MethodAccessException", i.Message); Assert.Equal(COR_E_METHODACCESS, i.HResult); Assert.Equal(i.InnerException.Message, "Created inner exception"); Assert.Equal(i.InnerException.HResult, ex.HResult); }
public static void Ctor_String_Exception() { string message = "Created MethodAccessException"; var innerException = new Exception("Created inner exception"); var exception = new MethodAccessException(message, innerException); Assert.Equal(message, exception.Message); Assert.Equal(COR_E_METHODACCESS, exception.HResult); Assert.Same(innerException, exception.InnerException); Assert.Equal(innerException.HResult, exception.InnerException.HResult); }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new instance of MethodAccessException."); try { MethodAccessException myException = new MethodAccessException(); if (myException == null) { TestLibrary.TestFramework.LogError("001.1", "MethodAccessException instance can not create correctly."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); retVal = false; } return retVal; }
// Returns true if the expected result is right // Returns false if the expected result is wrong public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new instance of MethodAccessException."); try { MethodAccessException myException = new MethodAccessException(); if (myException == null) { TestLibrary.TestFramework.LogError("001.1", "MethodAccessException instance can not create correctly."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); retVal = false; } return(retVal); }