Exemple #1
0
        public void Test_Do_ReturnsZero_WhenFileContainsOnlySpaces()
        {
            // テスト用のファイルを用意
            var fileName     = MethodBase.GetCurrentMethod().Name;
            var filePath     = Path.Combine(this.DirectoryPath, fileName);
            var fileEncoding = Encoding.UTF8;

            using (var stream = File.Create(filePath))
                using (var writer = new StreamWriter(stream, fileEncoding))
                {
                    writer.WriteLine(new string(' ', 5) + "a");
                    writer.WriteLine(new string(' ', 5) + "b");
                    writer.WriteLine(new string(' ', 5) + "c");
                    writer.Flush();
                }

            // テスト対象の処理を実行
            var method = new UsingBothTabsAndSpacesScoutingMethod();
            var actual = method.Do(new ScoutingClue()
            {
                FilePath = filePath,
                Encoding = fileEncoding
            });

            // テスト結果を検証
            Assert.AreEqual("0", actual);
        }
Exemple #2
0
        public void Test_Do_ReturnsZero_WhenFileIsBinary()
        {
            // テスト用のファイルを用意
            var fileName = MethodBase.GetCurrentMethod().Name;
            var filePath = Path.Combine(this.DirectoryPath, fileName);

            using (var stream = File.Create(filePath))
            {
                stream.Write(new byte[] { 0x0 }, 0, 1);
                stream.Flush();
            }

            // テスト対象の処理を実行
            var method = new UsingBothTabsAndSpacesScoutingMethod();
            var actual = method.Do(new ScoutingClue()
            {
                FilePath = filePath
            });

            // テスト結果を検証
            Assert.AreEqual("0", actual);
        }