public void Main_WriteExecutionData()
        {
            string view =
                @"Begin executing
Throw exception
Unexpected error: Arbitrary exception
Shutting down...";

            IntelliTect.TestTools.Console.ConsoleAssert.Expect(view,
                                                               () =>
            {
                ThrowingExceptions.Main();
            });
        }
예제 #2
0
파일: Program.cs 프로젝트: dealen/70-483
        private static void Exceptionhandling()
        {
            IRun ex = new ExceptionsBasics();

            //ex.Run();

            ex = new ExceptionWithFinally();
            //ex.Run();

            ex = new ExceptionInspecting();
            //ex.Run();

            ex = new ThrowingExceptions();
            //ex.Run();

            ex = new DispatcherThrowMethod();
            ex.Run();
        }
 public int ConvertHexCharToInteger_CharIsValid_ReturnsInteger(char c)
 {
     return(ThrowingExceptions.ConvertHexCharToInteger(c));
 }
 public string GenerateGreeting_ParametersAreValid_ReturnsGreeting(string hello, string[] addressee, int index)
 {
     return(ThrowingExceptions.GenerateGreeting(hello, addressee, index));
 }
 public void CheckBothParametersAndThrowException_ParameterIsNull_ThrowsArgumentNullException(object obj1, object obj2)
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.CheckBothParametersAndThrowException(obj1, obj2), "ThrowingExceptions.CheckBothParametersAndThrowException should throw an ArgumentNullException.");
 }
 public void GenerateGreeting_HelloIsNullOrEmpty_ThrowsArgumentNullException(string hello)
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GenerateGreeting(hello, Array.Empty <string>(), 0));
 }
 public void GenerateGreeting_AddresseeIsEmpty_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentException>(() => ThrowingExceptions.GenerateGreeting("Hello", Array.Empty <string>(), 0));
 }
 public void GenerateUserCode_DayIsOutOfRange_ThrowsArgumentOutOfRangeException(int day)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => ThrowingExceptions.GenerateUserCode("ABCD", day));
 }
 public void GetLastCharacter_StrIsNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GetLastCharacter(null));
 }
 public void CheckCandidateAgeAndThrowException_ParameterIsOutOfRange_ThrowsException(int candidateAge, bool isCandidateWoman)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => ThrowingExceptions.CheckCandidateAgeAndThrowException(candidateAge, isCandidateWoman));
 }
 public void GetArrayValue_IndexArrayIsNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GetArrayValue(null, 0, Array.Empty <string>()));
 }
 public void CheckEvenNumberAndThrowException_ParameterIsNotEven_ThrowsException(int evenNumber)
 {
     Assert.Throws <ArgumentException>(() => ThrowingExceptions.CheckEvenNumberAndThrowException(evenNumber), "ThrowingExceptions.CheckEvenNumberAndThrowException should throw a ArgumentException.");
 }
 public int CheckCandidateAgeAndThrowException_ParameterIsInRange_ReturnWithoutException(int candidateAge, bool isCandidateWoman)
 {
     return(ThrowingExceptions.CheckCandidateAgeAndThrowException(candidateAge, isCandidateWoman));
 }
 public int CheckEvenNumberAndThrowException_ParameterIsEven_ReturnWithoutException(int evenNumber)
 {
     return(ThrowingExceptions.CheckEvenNumberAndThrowException(evenNumber));
 }
 public void CheckBothStringsAndThrowException_ParameterIsNullOrEmpty_ThrowsArgumentNullException(string str1, string str2)
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.CheckBothStringsAndThrowException(str1, str2), "ThrowingExceptions.CheckBothStringsAndThrowException should throw an ArgumentNullException.");
 }
 public string CheckBothStringsAndThrowException_ParameterIsNotNullOrEmpty_ReturnWithoutException(string str1, string str2)
 {
     return(ThrowingExceptions.CheckBothStringsAndThrowException(str1, str2));
 }
 public void GenerateUserCode_CodeIsNullOrEmpty_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GenerateUserCode(null, 0));
 }
 public void GetArrayValue_IndexArrayIsEmpty_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ThrowingExceptions.GetArrayValue(Array.Empty <int>(), 0, Array.Empty <string>()));
 }
 public void GenerateUserCode_CodeLengthIsNotEqualsFour_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ThrowingExceptions.GenerateUserCode("ABC", 0));
 }
 public void GetArrayValue_ValueArrayIsNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GetArrayValue(new int[] { 0 }, 0, null));
 }
 public string GenerateUserCode_ParametersAreValid_ReturnsUserCode(string code, int day)
 {
     return(ThrowingExceptions.GenerateUserCode(code, day));
 }
 public void GetArrayValue_ValueArrayIsEmpty_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ThrowingExceptions.GetArrayValue(new int[] { 0 }, 0, Array.Empty <string>()));
 }
 public char GetLastCharacter_ValidStr_ReturnsResult(string str)
 {
     return(ThrowingExceptions.GetLastCharacter(str));
 }
 public void GetArrayValue_IndexArrayPositionIsOutOfRange_ThrowsIndexOutOfRangeException(int[] indexArray)
 {
     Assert.Throws <IndexOutOfRangeException>(() => ThrowingExceptions.GetArrayValue(indexArray, 0, new string[] { "value" }));
 }
 public void GenerateGreeting_AddresseeIsNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GenerateGreeting("Hello", null, 0));
 }
 public void GenerateUserCode_UsernameParameterIsIncorrect_ThrowsException(int day, int month, string username)
 {
     Assert.Throws <ArgumentNullException>(() => ThrowingExceptions.GenerateUserCode(day, month, username), "ThrowingExceptions.GenerateUserCode should throw an ArgumentNullException.");
 }
 public void GenerateGreeting_IndexIsOutOfRange_ThrowsArgumentNullException(int index)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => ThrowingExceptions.GenerateGreeting("Hello", new string[] { "world" }, index));
 }
 public string GetArrayValue_ParametersAreValid_ReturnsValue(int[] indexArray, int indexArrayPosition, string[] valueArray)
 {
     return(ThrowingExceptions.GetArrayValue(indexArray, indexArrayPosition, valueArray));
 }
 public void ConvertHexCharToInteger_CharIsInvalid_ThrowsArgumentException(char c)
 {
     Assert.Throws <ArgumentException>(() => ThrowingExceptions.ConvertHexCharToInteger(c));
 }
 public void CheckBothParametersAndThrowException_ParametersAreNotNull_ReturnsWithoutException(object obj1, object obj2)
 {
     ThrowingExceptions.CheckBothParametersAndThrowException(obj1, obj2);
 }