public static void TestFindHeaderBlockNotFound() { Headers headers = new Headers(); headers.HeaderBlocks.Add(new PreambleHeaderBlock()); headers.HeaderBlocks.Add(new VersionHeaderBlock(new byte[] { 4, 1, 2, 0, 0 })); headers.HeaderBlocks.Add(new DataHeaderBlock()); FileInfoEncryptedHeaderBlock fileInfoHeaderBlock = headers.FindHeaderBlock <FileInfoEncryptedHeaderBlock>(); Assert.That(fileInfoHeaderBlock, Is.Null); }
public static void TestNonUtcFileTimes(CryptoImplementation cryptoImplementation) { SetupAssembly.AssemblySetupCrypto(cryptoImplementation); FileInfoEncryptedHeaderBlock fileInfoHeaderBlock = new FileInfoEncryptedHeaderBlock(new V1AesCrypto(new V1Aes128CryptoFactory(), new V1DerivedKey(new Passphrase("nonutc")).DerivedKey, SymmetricIV.Zero128)); DateTime utcNow = New <INow>().Utc; DateTime localNow = utcNow.ToLocalTime(); fileInfoHeaderBlock.CreationTimeUtc = localNow; Assert.That(fileInfoHeaderBlock.CreationTimeUtc.Kind, Is.EqualTo(DateTimeKind.Utc), "The local time should be converted to UTC by the setter."); Assert.That(fileInfoHeaderBlock.CreationTimeUtc, Is.EqualTo(utcNow), "The setter should have set the time to value of local time converted to UTC."); fileInfoHeaderBlock.LastAccessTimeUtc = localNow; Assert.That(fileInfoHeaderBlock.LastAccessTimeUtc.Kind, Is.EqualTo(DateTimeKind.Utc), "The local time should be converted to UTC by the setter."); Assert.That(fileInfoHeaderBlock.LastAccessTimeUtc, Is.EqualTo(utcNow), "The setter should have set the time to value of local time converted to UTC."); fileInfoHeaderBlock.LastWriteTimeUtc = localNow; Assert.That(fileInfoHeaderBlock.LastWriteTimeUtc.Kind, Is.EqualTo(DateTimeKind.Utc), "The local time should be converted to UTC by the setter."); Assert.That(fileInfoHeaderBlock.LastWriteTimeUtc, Is.EqualTo(utcNow), "The setter should have set the time to value of local time converted to UTC."); }