public void InitializesFieldsProperly() { //Arrange var forsendelse = DomainUtility.GetDigitalDigitalPostWithNotificationMultipleDocumentsAndHigherSecurity(); var manifest = new Manifest(forsendelse); var cryptographicCertificate = forsendelse.PostInfo.Mottaker.Sertifikat; var signature = new Signature(forsendelse, manifest, DomainUtility.GetAvsenderCertificate()); var asiceAttachables = new List<IAsiceAttachable>(); asiceAttachables.AddRange(forsendelse.Dokumentpakke.Vedlegg); asiceAttachables.Add(forsendelse.Dokumentpakke.Hoveddokument); asiceAttachables.Add(manifest); asiceAttachables.Add(signature); var asiceAttachablesArray = asiceAttachables.ToArray(); var asiceAttachableProcessors = new List<AsiceAttachableProcessor>(); //Act var asiceArchive = new AsiceArchive(cryptographicCertificate, new GuidUtility(), asiceAttachableProcessors, asiceAttachablesArray); //Assert Assert.Equal(asiceAttachableProcessors, asiceArchive.AsiceAttachableProcessors); Assert.Equal(asiceAttachablesArray, asiceArchive.AsiceAttachables); }
public void ReturnsProperBytesCount() { //Arrange var forsendelse = DomainUtility.GetDigitalDigitalPostWithNotificationMultipleDocumentsAndHigherSecurity(); var manifest = new Manifest(forsendelse); var cryptographicCertificate = forsendelse.PostInfo.Mottaker.Sertifikat; var signature = new Signature(forsendelse, manifest, DomainUtility.GetAvsenderCertificate()); var asiceAttachables = new List<IAsiceAttachable>(); asiceAttachables.AddRange(forsendelse.Dokumentpakke.Vedlegg); asiceAttachables.Add(forsendelse.Dokumentpakke.Hoveddokument); asiceAttachables.Add(manifest); asiceAttachables.Add(signature); var asiceArchive = new AsiceArchive(cryptographicCertificate, new GuidUtility(), new List<AsiceAttachableProcessor>(), asiceAttachables.ToArray()); var expectedBytesCount = 0L; foreach (var dokument in asiceAttachables) { expectedBytesCount += dokument.Bytes.Length; } //Act var actualBytesCount = asiceArchive.UnzippedContentBytesCount; //Assert Assert.Equal(expectedBytesCount, actualBytesCount); }
internal static DocumentBundle Create(Forsendelse forsendelse, GuidUtility guidUtility, X509Certificate2 senderCertificate, IAsiceConfiguration asiceConfiguration) { var manifest = new Manifest(forsendelse); ValidateXmlAndThrowIfInvalid(manifest.Xml(), "Manifest"); var signature = new Signature(forsendelse, manifest, senderCertificate); ValidateXmlAndThrowIfInvalid(signature.Xml(), "Signatur"); var asiceAttachables = new List<IAsiceAttachable>(); asiceAttachables.AddRange(forsendelse.Dokumentpakke.Vedlegg); asiceAttachables.Add(forsendelse.Dokumentpakke.Hoveddokument); asiceAttachables.Add(manifest); asiceAttachables.Add(signature); var asiceAttachableProcessors = ConvertDocumentBundleProcessorsToAsiceAttachableProcessors(forsendelse, asiceConfiguration); var asiceArchive = new AsiceArchive(forsendelse.PostInfo.Mottaker.Sertifikat, guidUtility, asiceAttachableProcessors, asiceAttachables.ToArray()); return new DocumentBundle(asiceArchive.Bytes, asiceArchive.UnzippedContentBytesCount, asiceArchive.ContentId); }