Пример #1
0
        public void SerializeNoValueCompressed(KdbxVersion version, bool protect)
        {
            ProtectedBinary bin        = new ProtectedBinary(new byte[0], protect);
            KdbxBinary      binary     = new KdbxBinary(1, bin);
            XElement        serialized = binary.ToXml(
                new MockRng(),
                new KdbxSerializationParameters(version)
            {
                Compression = CompressionAlgorithm.GZip
            }
                );

            Assert.AreEqual(binary.Id.ToString(), serialized.Attribute("ID").Value, "ID should serialize properly");
            Assert.AreEqual("True", serialized.Attribute("Compressed").Value, "Compressed attribute should not be set");
            Assert.AreEqual("", serialized.Value, "XML value should serialize properly");
        }
Пример #2
0
        public void SerializeUncompressed(KdbxVersion version, bool protect)
        {
            ProtectedBinary bin        = new ProtectedBinary(ExpectedBytes, protect);
            KdbxBinary      binary     = new KdbxBinary(1, bin);
            XElement        serialized = binary.ToXml(
                new MockRng(),
                new KdbxSerializationParameters(version)
            {
                Compression = CompressionAlgorithm.None
            }
                );

            Assert.AreEqual(binary.Id.ToString(), serialized.Attribute("ID").Value, "ID should serialize properly");
            Assert.IsNull(serialized.Attribute("Compressed"), "Compressed attribute should not be set");
            Assert.AreEqual(Base64Uncompressed, serialized.Value, "XML value should serialize properly");
        }