Пример #1
0
        public void UnitIco_Misnamed()
        {
            var fName1 = @"Targets\Singles\DutchIco.jpeg";

            var dummy = new KaosDiags.Diags.Model(null);

            FormatBase fmt;

            using (Stream s1 = new FileStream(fName1, FileMode.Open))
            {
                FormatBase.Model fmtModel = FormatBase.Model.Create(s1, fName1, 0, 0, null, out FileFormat actual);
                fmt = fmtModel.Data;

                Assert.IsInstanceOfType(fmtModel, typeof(IcoFormat.Model));
                Assert.AreEqual("ico", actual.PrimaryName);

                Assert.IsTrue(fmt.Issues.MaxSeverity == Severity.Warning);
                Assert.AreEqual(1, fmt.Issues.Items.Count);
                Assert.AreEqual(1, fmt.Issues.RepairableCount);

                string err = fmtModel.IssueModel.Repair(index: 0);
                Assert.IsNull(err);
            }

            Assert.IsTrue(fmt.Issues.MaxSeverity == Severity.Warning);
            Assert.AreEqual(1, fmt.Issues.Items.Count);
            Assert.AreEqual(0, fmt.Issues.RepairableCount);
        }
Пример #2
0
        public void UnitCue_Rip1()
        {
            var targetDir     = @"Targets\Rips\Tester - 2000 - FLAC Repairable\";
            var expectedNames = new string[]
            {
                "01 - 4 frames of silence.flac", "02 - 8 frames of silence.flac", "03 - 12 frames of silence.flac",
                "!Cue with 4 files.cue", "Cue with 3 files.cue", "Tester - 2000 - FLAC Silence.log"
            };

            var diagsModel = new KaosDiags.Diags.Model(targetDir);

            diagsModel.Data.IsRepairEnabled = true;
            diagsModel.Data.ValidationFlags = Validations.Exists;

            var formatModels = new List <FormatBase.Model>();
            int actualIx     = 0;

            foreach (FormatBase.Model fmtModel in diagsModel.CheckRoot())
            {
                Assert.AreEqual(expectedNames[actualIx], fmtModel.Data.Name);
                formatModels.Add(fmtModel);
                ++actualIx;
            }

            Assert.AreEqual(expectedNames.Length, actualIx);

            var cue3 = (CueFormat.Model)formatModels[4];

            Assert.IsFalse(cue3.IssueModel.Data.HasError);
            Assert.AreEqual(1, cue3.IssueModel.Data.RepairableCount);

            var cue4 = (CueFormat.Model)formatModels[3];

            Assert.IsTrue(cue4.IssueModel.Data.HasError);
        }
Пример #3
0
        public void UnitM_FormatList()
        {
            // Spin up a Diags model to initialize the class variables.
            KaosDiags.Diags diags          = new KaosDiags.Diags.Model(null).Data;
            string          formatListText = KaosDiags.Diags.FormatListText;

            Assert.AreEqual(ExpectedTypes, formatListText);
        }
Пример #4
0
        public void UnitLogEac_StrictWeb()
        {
            var fName1 = @"Targets\Singles\Nightmare.log";
            var fName2 = @"Targets\Singles\EAC1NoHashOrCT.log";
            var model  = new KaosDiags.Diags.Model(null);

            // Uncomment next line for EAC log self-hash validation. Requires the interweb!
            // model.Data.HashFlags |= Hashes._WebCheck;

            //log1 has a self-hash
            Stream s1 = new FileStream(fName1, FileMode.Open);
            var    h1 = new byte[0x2C];

            s1.Read(h1, 0, h1.Length);
            var log1Model = LogEacFormat.CreateModel(s1, h1, fName1);

            log1Model.CalcHashes(model.Data.HashFlags, Validations.None);
            model.Data.ErrEscalator = IssueTags.StrictErr;
            log1Model.IssueModel.Escalate(model.Data.WarnEscalator, model.Data.ErrEscalator);
            var b1 = log1Model.Data;

            Assert.AreEqual(Severity.Error, b1.Issues.MaxSeverity);
            if ((model.Data.HashFlags & Hashes._WebCheck) != 0)
            {
                Assert.IsTrue(b1.ShIssue.Success == true);
            }
            else
            {
                Assert.IsNull(b1.ShIssue);
            }

            // log2 has no self-hash
            Stream s2 = new FileStream(fName2, FileMode.Open);
            var    h2 = new byte[0x2C];

            s2.Read(h2, 0, h1.Length);
            var log2Model = LogEacFormat.CreateModel(s2, h2, fName2);

            log2Model.CalcHashes(model.Data.HashFlags, 0);
            model.Data.ErrEscalator = IssueTags.StrictErr;
            log2Model.IssueModel.Escalate(model.Data.WarnEscalator, model.Data.ErrEscalator);
            var b2 = log2Model.Data;

            Assert.IsTrue(b2.Issues.HasError);
            if ((model.Data.HashFlags & Hashes._WebCheck) != 0)
            {
                Assert.IsTrue(b2.ShIssue.Success == false);
            }
            else
            {
                Assert.IsNull(b2.ShIssue);
            }
        }