Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# unit test exception using try catch

  [TestMethod]
        public void FromDirectoryIsnullorEmptyUsingTryCatch()
        {
            try
            {
                var fromDir = "";
                Util_Directory.Copy(fromDir, "", false, false);
            }
            catch (ArgumentException)
            {
                //test successfull here
                return;
            }

            Assert.Fail("Call to Copy method did not fail");
        }
Source by fluentassertions.com #
 
PREVIOUS NEXT
Tagged: #unit #test #exception #catch
ADD COMMENT
Topic
Name
3+5 =