コード例 #1
0
ファイル: PlainText.cs プロジェクト: FherStk/AutoCheck
        public void Compare()
        {
            var dest1 = Path.Combine(SamplesScriptFolder, "temp", "test3", "folder1");

            if (!Directory.Exists(dest1))
            {
                Directory.CreateDirectory(dest1);
            }

            var dest2 = Path.Combine(SamplesScriptFolder, "temp", "test3", "folder2");

            if (!Directory.Exists(dest2))
            {
                Directory.CreateDirectory(dest2);
            }

            var file1 = GetSampleFile(dest1, "sample1.txt");
            var file2 = GetSampleFile(dest2, "sample2.txt");

            File.Copy(GetSampleFile("lorem1.txt"), file1);
            File.Copy(GetSampleFile("lorem1.txt"), file2);

            using (var cd = new AutoCheck.Core.CopyDetectors.PlainText(0, "*.txt"))
            {
                Assert.DoesNotThrow(() => cd.Compare());

                Assert.DoesNotThrow(() => cd.Load(file1));
                Assert.DoesNotThrow(() => cd.Compare());

                Assert.DoesNotThrow(() => cd.Load(file2));
                Assert.DoesNotThrow(() => cd.Compare());
            }
        }
コード例 #2
0
ファイル: PlainText.cs プロジェクト: FherStk/AutoCheck
        public void CopyDetected_SameFiles()
        {
            var dest1 = Path.Combine(SamplesScriptFolder, "temp", "test4", "folder1");

            if (!Directory.Exists(dest1))
            {
                Directory.CreateDirectory(dest1);
            }

            var dest2 = Path.Combine(SamplesScriptFolder, "temp", "test4", "folder2");

            if (!Directory.Exists(dest2))
            {
                Directory.CreateDirectory(dest2);
            }

            var file1 = GetSampleFile(dest1, "sample1.txt");
            var file2 = GetSampleFile(dest2, "sample2.txt");

            File.Copy(GetSampleFile("lorem1.txt"), file1);
            File.Copy(GetSampleFile("lorem1.txt"), file2);

            using (var cd = new AutoCheck.Core.CopyDetectors.PlainText(1, "*.txt"))
            {
                Assert.DoesNotThrow(() => cd.Load(file1));
                Assert.DoesNotThrow(() => cd.Load(file2));
                Assert.DoesNotThrow(() => cd.Compare());

                Assert.Throws <ArgumentNullException>(() => cd.CopyDetected(string.Empty));
                Assert.Throws <ArgumentInvalidException>(() => cd.CopyDetected(_FAKE));

                Assert.IsTrue(cd.CopyDetected(dest1));
                Assert.IsTrue(cd.CopyDetected(dest2));
            }
        }
コード例 #3
0
ファイル: PlainText.cs プロジェクト: FherStk/AutoCheck
        public void GetDetails()
        {
            var dest1 = Path.Combine(SamplesScriptFolder, "temp", "test6", "folder1");

            if (!Directory.Exists(dest1))
            {
                Directory.CreateDirectory(dest1);
            }

            var dest2 = Path.Combine(SamplesScriptFolder, "temp", "test6", "folder2");

            if (!Directory.Exists(dest2))
            {
                Directory.CreateDirectory(dest2);
            }

            var file1 = GetSampleFile(dest1, "sample1.txt");
            var file2 = GetSampleFile(dest2, "sample2.txt");

            File.Copy(GetSampleFile("lorem1.txt"), file1);
            File.Copy(GetSampleFile("lorem2.txt"), file2);

            using (var cd = new AutoCheck.Core.CopyDetectors.PlainText(0.6f, "*.txt"))
            {
                Assert.DoesNotThrow(() => cd.Load(file1));
                Assert.DoesNotThrow(() => cd.Load(file2));

                Assert.DoesNotThrow(() => cd.Compare());

                var res = cd.GetDetails(dest1);
                Assert.AreEqual(dest1, res.folder);
                Assert.AreEqual(dest2, res.matches[0].folder);

                Assert.AreEqual(Path.GetFileName(file1), res.file);
                Assert.AreEqual(Path.GetFileName(file2), res.matches[0].file);

                Assert.AreEqual(0.589857578f, res.matches[0].match);
            }
        }