public static void TestClone() { V1IdTagHeaderBlock idTagHeaderBlock = new V1IdTagHeaderBlock("This is my tag!"); V1IdTagHeaderBlock cloned = (V1IdTagHeaderBlock)idTagHeaderBlock.Clone(); Assert.That(idTagHeaderBlock, Is.Not.SameAs(cloned), "The clone should not be the same reference."); Assert.That(cloned.IdTag, Is.EqualTo(idTagHeaderBlock.IdTag), "The clone should have the same id tag as the original."); }
public void TestFindFindIdTag() { using (MemoryStream testStream = new MemoryStream()) { AxCrypt1Guid.Write(testStream); new PreambleHeaderBlock().Write(testStream); new V1IdTagHeaderBlock("A test").Write(testStream); testStream.Position = 0; using (V1AxCryptReader axCryptReader = new V1AxCryptReader(new LookAheadStream(testStream))) { Assert.That(axCryptReader.Read(), Is.True, "We should be able to read the Guid"); Assert.That(axCryptReader.CurrentItemType, Is.EqualTo(AxCryptItemType.MagicGuid), "We're expecting to have found a MagicGuid"); Assert.That(axCryptReader.Read(), Is.True, "We should be able to read the next HeaderBlock"); Assert.That(axCryptReader.CurrentItemType, Is.EqualTo(AxCryptItemType.HeaderBlock), "This should be a header block"); Assert.That(axCryptReader.CurrentHeaderBlock.HeaderBlockType, Is.EqualTo(HeaderBlockType.Preamble), "This should be an Preamble block"); Assert.That(axCryptReader.Read(), Is.True, "We should be able to read the next HeaderBlock"); Assert.That(axCryptReader.CurrentItemType, Is.EqualTo(AxCryptItemType.HeaderBlock), "This should be a header block"); Assert.That(axCryptReader.CurrentHeaderBlock.HeaderBlockType, Is.EqualTo(HeaderBlockType.IdTag), "This should be an IdTag block"); V1IdTagHeaderBlock idTagHeaderBlock = (V1IdTagHeaderBlock)axCryptReader.CurrentHeaderBlock; Assert.That(idTagHeaderBlock.IdTag, Is.EqualTo("A test"), "We're expecting to be able to read the same tag we wrote"); } } }