コード例 #1
0
        public void Test_Sha1_2()
        {
            var fn = @"Targets\Hashes\Bad01.sha1";

            using (var fs = new FileStream(fn, FileMode.Open, FileAccess.Read))
            {
                var file = new FileInfo(fn);
                var hdr  = new byte[0x20];
                var got  = fs.Read(hdr, 0, hdr.Length);
                Assert.AreEqual(hdr.Length, got);

                Sha1Format.Model shaModel = Sha1Format.CreateModel(fs, hdr, fs.Name);
                Assert.IsNotNull(shaModel);

                Sha1Format sha = shaModel.Data;

                Assert.IsTrue(sha.Issues.MaxSeverity == Severity.NoIssue);
                Assert.AreEqual(0, sha.Issues.Items.Count);
                Assert.AreEqual(2, sha.HashedFiles.Items.Count);

                shaModel.CalcHashes(0, Validations.SHA1);
                Assert.AreEqual(2, sha.Issues.Items.Count);
                Assert.AreEqual(Severity.Error, sha.Issues.MaxSeverity);
            }
        }
コード例 #2
0
ファイル: TestSha1.cs プロジェクト: kaosborn/Filebert
        public void UnitSha1_Bad()
        {
            var fName1 = @"Targets\Hashes\Bad01.sha1";

            using (Stream fs = new FileStream(fName1, FileMode.Open, FileAccess.Read))
            {
                var hdr = new byte[0x20];
                var got = fs.Read(hdr, 0, hdr.Length);
                Assert.AreEqual(hdr.Length, got);

                Sha1Format.Model sha1Model = Sha1Format.CreateModel(fs, hdr, fName1);
                Sha1Format       sha1      = sha1Model.Data;

                Assert.AreEqual(Severity.NoIssue, sha1.Issues.MaxSeverity);
                Assert.AreEqual(0, sha1.Issues.Items.Count);
                Assert.AreEqual(2, sha1.HashedFiles.Items.Count);

                sha1Model.CalcHashes(0, Validations.SHA1);
                Assert.AreEqual(2, sha1.Issues.Items.Count);
                Assert.AreEqual(Severity.Error, sha1.Issues.MaxSeverity);
            }
        }