Example #1
0
        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));
            }
        }
Example #2
0
        public void CopyDetected_DifferentFiles()
        {
            var dest1 = Path.Combine(SamplesScriptFolder, "temp", "test5", "folder1");

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

            var dest2 = Path.Combine(SamplesScriptFolder, "temp", "test5", "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());

                Assert.IsFalse(cd.CopyDetected(dest1));
                Assert.IsFalse(cd.CopyDetected(dest2));
            }

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

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

                Assert.IsTrue(cd.CopyDetected(dest1));
                Assert.IsTrue(cd.CopyDetected(dest2));
            }
        }