public void ShouldThrowXmlExceptionIfResultNull() { // pass the empty file to provoke the exception var path = @"C:\Users\Nino\Desktop\test\file2.xml"; IFileReader reader = new FileReader(); var ex = Assert.Throws<XmlException>(() => reader.GetContent(path)); Assert.Equal(ex.GetType(), typeof(XmlException)); }
public void ShouldReturnCorrectExceptionForBadInput() { string input = string.Empty; IFileReader reader = new FileReader(); ArgumentException ex = Assert.Throws<ArgumentNullException>(() => reader.TryGetFile(input)); Assert.Equal("path", ex.ParamName); }
public void ShouldNotReturnTrueIfPathDoesNotExist() { string path = @"C:\Users\Nino\Desktop\test2"; IFileReader fileReader = new FileReader(); var result = fileReader.TryGetFile(path); Assert.Equal(false, result); }
public void ShouldReturnArgumentNullException() { string param = string.Empty; string paramName = "input"; IFileReader reader = new FileReader(); ArgumentException ex = Assert.Throws<ArgumentNullException>(() => reader.PreCheckInput(param, paramName)); Assert.Equal(paramName, ex.ParamName); Assert.Equal(ex.GetType(), typeof(ArgumentNullException)); }