private async Task ExpectUnlockError(KdbxParserCode error, bool expectIdentical = true) { CancellationTokenSource cts = new CancellationTokenSource(); KdbxDecryptionResult result = await this.reader.DecryptFileAsync(await this.thisTestInfo.Database.AsIStorageFile.OpenReadAsync(), this.thisTestInfo.Password, this.thisTestInfo.Keyfile, cts.Token); if (result.Result == ReaderResult.Success) { KdbxDocument oldDocument = result.GetDocument(); XElement newXml = oldDocument.ToXml(this.reader.HeaderData.GenerateRng(), result.Parameters); KdbxDocument newDocument = new KdbxDocument( newXml, this.reader.HeaderData.ProtectedBinaries, this.reader.HeaderData.GenerateRng(), result.Parameters ); Assert.AreEqual(oldDocument, newDocument); } Assert.AreEqual(error, result.Result.Code); }
/// <summary> /// A <see cref="ReaderResult"/> that simply wraps a <see cref="KdbxParserCode"/> with no further details. /// </summary> /// <param name="code"></param> /// <param name="ex"></param> public ReaderResult(KdbxParserCode code, Exception ex) { this.code = code; this.details = ex.Message; }
/// <summary> /// A <see cref="ReaderResult"/> that simply wraps a <see cref="KdbxParserCode"/> with no further details. /// </summary> /// <param name="code"></param> /// <param name="details"></param> public ReaderResult(KdbxParserCode code, string details) { this.code = code; this.details = details; }
/// <summary> /// A <see cref="ReaderResult"/> that simply wraps a <see cref="KdbxParserCode"/> with no further details. /// </summary> /// <param name="code"></param> public ReaderResult(KdbxParserCode code) { this.code = code; this.details = string.Empty; }