< Summary

Information
Class: EncodingDetectorTests.EncodingTests
Assembly: encodingdetectortests.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\EncodingDetectorTests\EncodingTests.cs
Line coverage
95%
Covered lines: 23
Uncovered lines: 1
Coverable lines: 24
Total lines: 49
Line coverage: 95.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBlocks covered Blocks not covered
EncodingTests()40
GetProjectDirectory()123
IsUtf8ShouldPass()40
IsNotUtf8ShouldNotPass()40

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\EncodingDetectorTests\EncodingTests.cs

#LineLine coverage
 1using ValidateLib.Encoding.Detection;
 2
 3namespace EncodingDetectorTests
 4{
 5    public class EncodingTests
 6    {
 7        private readonly string testFilesPath;
 8
 19        public EncodingTests()
 110        {
 111            string projectDirectory = GetProjectDirectory();
 112            testFilesPath = Path.Combine(projectDirectory, "TestFiles");
 113        }
 14        static string GetProjectDirectory()
 115        {
 116            string? currentDirectory = Directory.GetCurrentDirectory();
 17
 118            while (!string.IsNullOrEmpty(currentDirectory))
 119            {
 120                string[] projectFiles = Directory.GetFiles(currentDirectory, "*.csproj");
 21
 122                if (projectFiles.Length > 0)
 123                    return currentDirectory;
 124                currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
 125            }
 26
 027            throw new Exception("Could not find project directory.");
 128        }
 29
 30
 31        [Fact]
 32        public void IsUtf8ShouldPass()
 133        {
 34
 135            string testFilePath = Path.Combine(testFilesPath, "Utf8.txt");
 136            Assert.True(EncodingDetector.IsUtf8(testFilePath));
 37
 138        }
 39
 40        [Fact]
 41        public void IsNotUtf8ShouldNotPass()
 142        {
 43
 144            string testFilePath = Path.Combine(testFilesPath, "NotUtf8.txt");
 145            Assert.False(EncodingDetector.IsUtf8(testFilePath));
 46
 147        }
 48    }
 49}