public void Converts_document_successfully()
            {
                //Arrange
                const string   subject       = "Subject";
                const string   message       = "Message";
                const FileType fileType      = FileType.Pdf;
                var            documentBytes = new byte[] { 0x21, 0x22 };

                var source = new Document(
                    subject,
                    message,
                    fileType,
                    documentBytes
                    );

                var expected = new directdocument
                {
                    title       = subject,
                    description = message,
                    href        = source.FileName,
                    mime        = "application/pdf"
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #2
0
            public void Converts_signer_with_contact_information_identifier()
            {
                //Arrange
                var source = new Signer(new ContactInformation {
                    Email = new Email("*****@*****.**")
                });

                var expected = new portalsigner
                {
                    Item  = new enabled(),
                    Item1 = new notifications
                    {
                        Items = new object[] { new email {
                                                   address = ((ContactInformation)source.Identifier).Email.Address
                                               } }
                    },
                    onbehalfof          = signingonbehalfof.SELF,
                    onbehalfofSpecified = true,
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Exemple #3
0
            public void SmsNotification()
            {
                //Arrange
                var atTimes = new List <DateTime> {
                    DateTime.Now, DateTime.Now.AddHours(3)
                };
                var afterHours = new List <int> {
                    4, 5
                };

                var source = new SmsNotification();

                source.NotifyAfterHours.AddRange(afterHours);
                source.NotifyAtTimes.AddRange(atTimes);

                var expectedDto = new smsnotification
                {
                    afterhours = afterHours.ToArray(),
                    at         = atTimes.Select(a => new listedtime {
                        timeSpecified = true, time = a
                    }).ToArray()
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actual);
            }
Exemple #4
0
            public void Converts_portal_job_with_polling_queue_successfully()
            {
                //Arrange
                var document           = DomainUtility.GetPortalDocument();
                var signers            = DomainUtility.GetSigners(2);
                var reference          = "reference";
                var custompollingqueue = "CustomPollingQueue";
                var sender             = new Sender(BringPublicOrganizationNumber, new PollingQueue(custompollingqueue));
                var source             = new Job(document, signers, reference, sender);

                var expected = new portalsignaturejobrequest
                {
                    reference    = reference,
                    pollingqueue = custompollingqueue
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #5
0
            public void Converts_portal_document_successfully()
            {
                //Arrange
                var source = new Document("subject", "message", FileType.Pdf, new byte[] { 0xb2, 0xb3 })
                {
                    NonsensitiveTitle = "NonsensitiveTitle"
                };
                var expected = new portaldocument
                {
                    title             = source.Title,
                    nonsensitivetitle = source.NonsensitiveTitle,
                    description       = source.Message,
                    href = source.FileName,
                    mime = source.MimeType
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Exemple #6
0
            public void PrintReturnRecipientFromForeignAddress()
            {
                //Arrange
                var source = new PrintReturnRecipient(
                    "Name",
                    new ForeignAddress(
                        CountryIdentifier.Country,
                        "NORGE",
                        "Adresselinje1",
                        "Adresselinje2",
                        "Adresselinje3",
                        "Adresselinje4"
                        ));

                var expectedDto = new printrecipient
                {
                    name = source.Name,
                    Item = new foreignaddress
                    {
                        ItemElementName = ItemChoiceType2.country,
                        Item            = ((ForeignAddress)source.Address).CountryIdentifierValue,
                        addressline1    = source.Address.AddressLine1,
                        addressline2    = source.Address.AddressLine2,
                        addressline3    = source.Address.AddressLine3,
                        addressline4    = ((ForeignAddress)source.Address).Addressline4
                    }
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);
            }
Exemple #7
0
            public void PrintReturnRecipientFromNorwegianAddress()
            {
                //Arrange
                var source = new PrintReturnRecipient(
                    "Name",
                    new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3"));

                var expectedDto = new printrecipient
                {
                    name = source.Name,
                    Item = new norwegianaddress
                    {
                        zipcode      = ((NorwegianAddress)source.Address).PostalCode,
                        city         = ((NorwegianAddress)source.Address).City,
                        addressline1 = source.Address.AddressLine1,
                        addressline2 = source.Address.AddressLine2,
                        addressline3 = source.Address.AddressLine3
                    }
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);
            }
Exemple #8
0
            public void Converts_notifications_with_sms_and_email_successfully()
            {
                //Arrange
                var sms   = new Sms("99999999");
                var email = new Email("*****@*****.**");

                var source   = new Notifications(sms, email);
                var expected = new notifications
                {
                    Items = new object[]
                    {
                        new email {
                            address = email.Address
                        },
                        new sms {
                            number = sms.Number
                        }
                    }
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Exemple #9
0
            public void Converts_signer_identified_by_sms()
            {
                //Arrange
                var source = new Signer(
                    new ContactInformation {
                    Sms = new Sms("11111111")
                }
                    );

                var expected = new portalsigner
                {
                    Item  = new enabled(),
                    Item1 = new notifications
                    {
                        Items = new object[]
                        {
                            new sms {
                                number = "11111111"
                            }
                        }
                    },
                    onbehalfof          = signingonbehalfof.SELF,
                    onbehalfofSpecified = true,
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Exemple #10
0
            public void ForeignAddress()
            {
                //Arrange
                var source = new ForeignAddress(
                    CountryIdentifier.Countrycode,
                    "SE",
                    "Adresselinje1",
                    "Adresselinje2",
                    "Adresselinje3",
                    "Adresselinje4"
                    );

                var expectedDto = new foreignaddress
                {
                    ItemElementName = ItemChoiceType2.countrycode,
                    Item            = "SE",
                    addressline1    = source.AddressLine1,
                    addressline2    = source.AddressLine2,
                    addressline3    = source.AddressLine3,
                    addressline4    = source.Addressline4
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);
            }
Exemple #11
0
            public void Converts_signer_with_notifications_using_lookup_successfully()
            {
                //Arrange
                var source = new Signer(
                    new PersonalIdentificationNumber("11111111111"),
                    new NotificationsUsingLookup()
                    );
                var expected = new portalsigner
                {
                    Item  = ((PersonalIdentificationNumber)source.Identifier).Value,
                    Item1 = new notificationsusinglookup {
                        email = new enabled()
                    },
                    onbehalfof          = signingonbehalfof.SELF,
                    onbehalfofSpecified = true,
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
            public void Converts_signer_with_signer_identifier_successfully()
            {
                //Arrange
                const string customIdentifier = "custom-identifier";

                var source = new Signer(new CustomIdentifier(customIdentifier))
                {
                    OnBehalfOf = OnBehalfOf.Other
                };
                var expected = new directsigner
                {
                    ItemElementName     = ItemChoiceType.signeridentifier,
                    Item                = customIdentifier,
                    onbehalfofSpecified = true,
                    onbehalfof          = signingonbehalfof.OTHER
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #13
0
            public void Converts_signer_with_pin_and_notifications_successfully()
            {
                //Arrange
                var source = new Signer(
                    new PersonalIdentificationNumber("11111111111"),
                    new Notifications(new Email("*****@*****.**"))
                    );
                var expected = new portalsigner
                {
                    Item  = ((PersonalIdentificationNumber)source.Identifier).Value,
                    Item1 = new notifications
                    {
                        Items = new object[]
                        {
                            new email {
                                address = source.Notifications.Email.Address
                            }
                        }
                    },
                    onbehalfof          = signingonbehalfof.SELF,
                    onbehalfofSpecified = true,
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Exemple #14
0
            public void PrintIfUnread()
            {
                //Arrange
                DateTime     printifunreadafter = DateTime.Now.AddDays(3);
                PrintDetails printDetails       = new PrintDetails(
                    new PrintRecipient(
                        "Name",
                        new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3")),
                    new PrintReturnRecipient(
                        "ReturnName",
                        new NorwegianAddress("0001", "OsloRet", "Addr1Ret", "Addr2Ret", "Addr3Ret")));

                var source        = new PrintIfUnread(printifunreadafter, printDetails);
                var sourceAddress = source.PrintDetails.PrintRecipient.Address;
                var returnAddress = source.PrintDetails.PrintReturnRecipient.Address;

                var expectedDtoPrintDetails = new printdetails
                {
                    recipient = new printrecipient
                    {
                        name = source.PrintDetails.PrintRecipient.Name,
                        Item = new norwegianaddress
                        {
                            zipcode      = ((NorwegianAddress)sourceAddress).PostalCode,
                            city         = ((NorwegianAddress)sourceAddress).City,
                            addressline1 = sourceAddress.AddressLine1,
                            addressline2 = sourceAddress.AddressLine2,
                            addressline3 = sourceAddress.AddressLine3
                        }
                    },
                    returnaddress = new printrecipient
                    {
                        name = source.PrintDetails.PrintReturnRecipient.Name,
                        Item = new norwegianaddress
                        {
                            zipcode      = ((NorwegianAddress)returnAddress).PostalCode,
                            city         = ((NorwegianAddress)returnAddress).City,
                            addressline1 = returnAddress.AddressLine1,
                            addressline2 = returnAddress.AddressLine2,
                            addressline3 = returnAddress.AddressLine3
                        }
                    }
                };

                var expectedDto = new printifunread
                {
                    printifunreadafter = printifunreadafter,
                    printdetails       = expectedDtoPrintDetails
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);

                Assert.Null(DataTransferObjectConverter.ToDataTransferObject((IPrintIfUnread)null));
            }
Exemple #15
0
            public void PrintDetails()
            {
                //Arrange
                var source = new PrintDetails(
                    new PrintRecipient(
                        "Name",
                        new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3")),
                    new PrintReturnRecipient(
                        "ReturnName",
                        new NorwegianAddress("0001", "OsloRet", "Addr1Ret", "Addr2Ret", "Addr3Ret")));

                List <PrintInstruction> printinstruction = new List <PrintInstruction>();

                printinstruction.Add(new PrintInstruction("test", "testing"));
                source.PrintInstructions = new PrintInstructions(printinstruction);

                var sourceAddress = source.PrintRecipient.Address;
                var returnAddress = source.PrintReturnRecipient.Address;

                var expectedDto = new printdetails
                {
                    recipient = new printrecipient
                    {
                        name = source.PrintRecipient.Name,
                        Item = new norwegianaddress
                        {
                            zipcode      = ((NorwegianAddress)sourceAddress).PostalCode,
                            city         = ((NorwegianAddress)sourceAddress).City,
                            addressline1 = sourceAddress.AddressLine1,
                            addressline2 = sourceAddress.AddressLine2,
                            addressline3 = sourceAddress.AddressLine3
                        }
                    },
                    returnaddress = new printrecipient
                    {
                        name = source.PrintReturnRecipient.Name,
                        Item = new norwegianaddress
                        {
                            zipcode      = ((NorwegianAddress)returnAddress).PostalCode,
                            city         = ((NorwegianAddress)returnAddress).City,
                            addressline1 = returnAddress.AddressLine1,
                            addressline2 = returnAddress.AddressLine2,
                            addressline3 = returnAddress.AddressLine3
                        }
                    },
                    printinstructions = new printinstruction[] { new printinstruction {
                                                                     key = "test", value = "testing"
                                                                 } }
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);

                Assert.Null(DataTransferObjectConverter.ToDataTransferObject((IPrintDetails)null));
            }
            public void Converts_manifest_with_signature_type_successfully()
            {
                //Arrange
                const string organizationNumberSender     = "12345678902";
                const string documentSubject              = "Subject";
                const string documentMessage              = "Message";
                var          pdfDocumentBytes             = GetPdfDocumentBytes();
                var          personalIdentificationNumber = "12345678901";
                var          expectedMimeType             = "application/pdf";

                var source = new Manifest(
                    new Sender(organizationNumberSender),
                    new Document(documentSubject, documentMessage, FileType.Pdf, pdfDocumentBytes),
                    new[]
                {
                    new Signer(new PersonalIdentificationNumber(personalIdentificationNumber))
                    {
                        SignatureType = SignatureType.AdvancedSignature
                    }
                }
                    );

                var expected = new directsignaturejobmanifest
                {
                    sender = new sender {
                        organizationnumber = organizationNumberSender
                    },
                    document = new directdocument
                    {
                        title       = documentSubject,
                        description = documentMessage,
                        href        = source.Document.FileName,
                        mime        = expectedMimeType
                    },
                    signer = new[]
                    {
                        new directsigner
                        {
                            ItemElementName        = ItemChoiceType.personalidentificationnumber,
                            Item                   = personalIdentificationNumber,
                            signaturetype          = signaturetype.ADVANCED_ELECTRONIC_SIGNATURE,
                            signaturetypeSpecified = true,
                            onbehalfof             = signingonbehalfof.SELF,
                            onbehalfofSpecified    = true
                        }
                    }
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #17
0
            public void Converts_manifest_without_availability_successfully()
            {
                //Arrange
                const string organizationNumberSender = "12345678902";
                var          source = new Manifest(new Sender(organizationNumberSender), DomainUtility.GetPortalDocument(),
                                                   new List <Signer>
                {
                    new Signer(new PersonalIdentificationNumber("01043100358"), new NotificationsUsingLookup()),
                    new Signer(new PersonalIdentificationNumber("01043100319"), new NotificationsUsingLookup())
                });

                var expected = new portalsignaturejobmanifest
                {
                    sender = new sender {
                        organizationnumber = organizationNumberSender
                    },
                    document = new portaldocument
                    {
                        title       = source.Document.Title,
                        description = source.Document.Message,
                        href        = source.Document.FileName,
                        mime        = source.Document.MimeType
                    },
                    signers = new[]
                    {
                        new portalsigner
                        {
                            Item  = ((PersonalIdentificationNumber)source.Signers.ElementAt(0).Identifier).Value,
                            Item1 = new notificationsusinglookup {
                                email = new enabled()
                            },
                            onbehalfof          = signingonbehalfof.SELF,
                            onbehalfofSpecified = true,
                        },
                        new portalsigner
                        {
                            Item  = ((PersonalIdentificationNumber)source.Signers.ElementAt(1).Identifier).Value,
                            Item1 = new notificationsusinglookup {
                                email = new enabled()
                            },
                            onbehalfof          = signingonbehalfof.SELF,
                            onbehalfofSpecified = true,
                        }
                    }
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #18
0
            public void Successful_manifest_to_bytes()
            {
                //Arrange
                var manifest = DomainUtility.GetPortalManifest();
                var manifestDataTranferObject = DataTransferObjectConverter.ToDataTransferObject(manifest);
                var expectedResult            = SerializeUtility.Serialize(manifestDataTranferObject);

                //Act
                var bytes        = manifest.Bytes;
                var actualResult = Encoding.UTF8.GetString(bytes);

                //Assert
                Assert.Equal(expectedResult, actualResult);
            }
            public void ReturnsCorrectDataForIdentification()
            {
                //Arrange
                var identification = new Identification(new RecipientById(IdentificationType.PersonalIdentificationNumber, "00000000000"));

                //Act
                var action  = new IdentificationAction(identification);
                var content = action.RequestContent;

                //Assert
                var identificationDto = DataTransferObjectConverter.ToDataTransferObject(identification);
                var expected          = SerializeUtil.Serialize(identificationDto);

                Assert.Equal(expected, content.InnerXml);
            }
Exemple #20
0
            public void IdentificationByOrganizationNumber()
            {
                //Arrange
                var source      = new Identification(new RecipientById(IdentificationType.OrganizationNumber, "123456789"));
                var expectedDto = new identification
                {
                    ItemElementName = ItemChoiceType.organisationnumber,
                    Item            = ((RecipientById)source.DigipostRecipient).Id
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);
            }
Exemple #21
0
            public void InitializesClassAndParentProperties()
            {
                //Arrange
                var businessCertificate = CoreDomainUtility.GetTestCertificate();
                var clientConfiguration = CoreDomainUtility.GetClientConfiguration();
                var directJob           = new Job(DomainUtility.GetDirectDocument(), DomainUtility.GetSigner(), "reference", DomainUtility.GetExitUrls(), CoreDomainUtility.GetSender());
                var serializedJob       = SerializeUtility.Serialize(DataTransferObjectConverter.ToDataTransferObject(directJob));

                var asiceBundle = DirectAsiceGenerator.CreateAsice(directJob, businessCertificate, clientConfiguration);

                //Act
                var action = new CreateAction(directJob, asiceBundle);

                //Assert
                Assert.Equal(directJob, action.RequestContent);
                Assert.Equal(serializedJob, action.RequestContentXml.InnerXml);

                Assert.Null(action.MultipartFormDataContent);
            }
Exemple #22
0
            public void NorwegianAddress()
            {
                //Arrange
                var source = new NorwegianAddress("0001", "Oslo", "Addr1", "Addr2", "Addr3");

                var expectedDto = new norwegianaddress
                {
                    zipcode      = source.PostalCode,
                    city         = source.City,
                    addressline1 = source.AddressLine1,
                    addressline2 = source.AddressLine2,
                    addressline3 = source.AddressLine3
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);
            }
Exemple #23
0
            public void Converts_notifications_using_lookup_successfully()
            {
                //Arrange
                var source = new NotificationsUsingLookup {
                    SmsIfAvailable = true
                };
                var expected = new notificationsusinglookup {
                    email = new enabled(), sms = new enabled()
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Exemple #24
0
        public static document ToDataTransferObject(IDocument document)
        {
            document documentDto;

            if (document is Invoice)
            {
                var invoice = (Invoice)document;

                var invoiceDto = new invoice
                {
                    amount  = invoice.Amount,
                    duedate = invoice.Duedate,
                    kid     = invoice.Kid,
                    account = invoice.Account
                };

                documentDto = invoiceDto;
            }
            else
            {
                documentDto = new document();
            }

            documentDto.subject                      = document.Subject;
            documentDto.filetype                     = document.FileType;
            documentDto.authenticationlevel          = document.AuthenticationLevel.ToAuthenticationLevel();
            documentDto.authenticationlevelSpecified = true;
            documentDto.sensitivitylevel             = document.SensitivityLevel.ToSensitivityLevel();
            documentDto.sensitivitylevelSpecified    = true;
            documentDto.smsnotification              = DataTransferObjectConverter.ToDataTransferObject(document.SmsNotification);
            documentDto.uuid = document.Guid;

            if (document.DataType != null)
            {
                var xmldoc = new XmlDocument();
                xmldoc.LoadXml(document.DataType);
                documentDto.datatype = xmldoc.DocumentElement;
            }

            return(documentDto);
        }
            public void Converts_direct_job_successfully_with_polling_queue_successfully()
            {
                var document        = DomainUtility.GetDirectDocument();
                var signer          = DomainUtility.GetSigner();
                var reference       = "reference";
                var exitUrls        = DomainUtility.GetExitUrls();
                var statusretrieval = statusretrievalmethod.WAIT_FOR_CALLBACK;
                var pollingQueue    = new PollingQueue("CustomPollingQueue");
                var sender          = new Sender(BringPublicOrganizationNumber, pollingQueue);

                var source = new Job(
                    document,
                    signer,
                    reference,
                    exitUrls,
                    sender);

                var expected = new directsignaturejobrequest
                {
                    reference = reference,
                    exiturls  = new exiturls
                    {
                        completionurl = source.ExitUrls.CompletionUrl.AbsoluteUri,
                        rejectionurl  = source.ExitUrls.RejectionUrl.AbsoluteUri,
                        errorurl      = source.ExitUrls.ErrorUrl.AbsoluteUri
                    },
                    statusretrievalmethod          = statusretrieval,
                    statusretrievalmethodSpecified = true,
                    pollingqueue = pollingQueue.Name
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
            public void Converts_sender_successfully()
            {
                //Arrange
                const string organizationNumber = "123456789";

                var source   = new Sender(organizationNumber);
                var expected = new sender
                {
                    organizationnumber = organizationNumber
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #27
0
            public void RecipientById()
            {
                //Arrange
                var source = new RecipientById(
                    IdentificationType.DigipostAddress,
                    "ola.nordmann#2233"
                    );

                var expectedDto = new messagerecipient
                {
                    ItemElementName = ItemChoiceType1.digipostaddress,
                    Item            = "ola.nordmann#2233",
                    printdetails    = null //TODO: Implementer print!
                };

                //Act
                var actualDto = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                Comparator.AssertEqual(expectedDto, actualDto);
            }
            public void Converts_exit_urls_successfully()
            {
                //Arrange
                var source   = DomainUtility.GetExitUrls();
                var expected = new exiturls
                {
                    completionurl = source.CompletionUrl.AbsoluteUri,
                    rejectionurl  = source.RejectionUrl.AbsoluteUri,
                    errorurl      = source.ErrorUrl.AbsoluteUri
                };

                //Act
                var result = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #29
0
        public static message ToDataTransferObject(IMessage message)
        {
            var primaryDocumentDataTransferObject = ToDataTransferObject(message.PrimaryDocument);

            var messageDto = new message
            {
                Item            = message.Sender.Id,
                primarydocument = primaryDocumentDataTransferObject,
                messageid       = message.Id,
                recipient       = DataTransferObjectConverter.ToDataTransferObject(message.DigipostRecipient)
            };

            messageDto.recipient.printdetails = DataTransferObjectConverter.ToDataTransferObject(message.PrintDetails);

            if (message.DigipostRecipient is RecipientById)
            {
                var identificationType = ((RecipientById)message.DigipostRecipient).IdentificationType;
                messageDto.recipient.ItemElementName = identificationType.ToItemChoiceType1();
            }
            else if (message.DigipostRecipient is RecipientByNameAndAddress)
            {
                messageDto.recipient.ItemElementName = ItemChoiceType1.nameandaddress;
            }

            messageDto.attachment = message.Attachments.Select(ToDataTransferObject).ToArray();

            if (message.DeliveryTimeSpecified)
            {
                messageDto.deliverytime          = message.DeliveryTime.Value;
                messageDto.deliverytimeSpecified = true;
            }

            if (message.PrintIfUnreadAfterSpecified)
            {
                messageDto.printifunread = DataTransferObjectConverter.ToDataTransferObject(message.PrintIfUnread);
            }

            return(messageDto);
        }
Exemple #30
0
            public void Converts_on_behalf_of()
            {
                //Arrange
                var source = new Signer(
                    new ContactInformation {
                    Email = new Email("*****@*****.**")
                }
                    )
                {
                    OnBehalfOf = OnBehalfOf.Other
                };

                var expected = new portalsigner
                {
                    Item  = new enabled(),
                    Item1 = new notifications
                    {
                        Items = new object[]
                        {
                            new email {
                                address = "*****@*****.**"
                            }
                        }
                    },
                    onbehalfofSpecified = true,
                    onbehalfof          = signingonbehalfof.OTHER
                };

                //Act
                var actual = DataTransferObjectConverter.ToDataTransferObject(source);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }