예제 #1
0
        public void BinaryCompareTest()
        {
            var random          = new Random();
            var content         = Enumerable.Range(0, 10).Select(x => (byte)random.Next(0, 254)).ToArray();
            var mismatchContent = content.Append((byte)random.Next(0, 254)).ToArray();

            // binary match item should be true
            var a = Path.Combine(_path, "a");

            File.WriteAllBytes(a, content);
            using var fa = File.OpenRead(a);
            Assert.True(FileChecker.Compare(content, fa));

            // binary miss-match item should be false
            var b = Path.Combine(_path, "b");

            File.WriteAllBytes(b, mismatchContent);
            using var fb = File.OpenRead(b);
            Assert.False(FileChecker.Compare(content, fb));
        }