Пример #1
0
        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));
        }
Пример #2
0
        public void ShouldReturnCorrectExceptionForBadInput()
        {
            string input = string.Empty;
            IFileReader reader = new FileReader();

            ArgumentException ex = Assert.Throws<ArgumentNullException>(() => reader.TryGetFile(input));

            Assert.Equal("path", ex.ParamName);
        }
Пример #3
0
        public void ShouldNotReturnTrueIfPathDoesNotExist()
        {
            string path = @"C:\Users\Nino\Desktop\test2";

            IFileReader fileReader = new FileReader();
            var result = fileReader.TryGetFile(path);

            Assert.Equal(false, result);
        }
Пример #4
0
        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));
        }