Exemple #1
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);
            }
        protected virtual bool IsValueChanged(string propertyName)
        {
            if (IsComplexType(propertyName))
            {
                var prop         = DbEntry.Reference(propertyName);
                var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType;

                object originalValue = OriginalValue(propertyName);

                Comparator comparator = ComparatorFactory.GetComparator(propertyType);

                var changed = (StateOfEntity() == EntityState.Modified &&
                               prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue));
                return(changed);
            }
            else
            {
                var prop         = DbEntry.Property(propertyName);
                var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType;

                object originalValue = OriginalValue(propertyName);

                Comparator comparator = ComparatorFactory.GetComparator(propertyType);

                var changed = (StateOfEntity() == EntityState.Modified &&
                               prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue));
                return(changed);
            }
        }
            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 #4
0
            public void Convert_person()
            {
                //Arrange
                var source = new HentPersonerRespons
                {
                    Person = new[]
                    {
                        GetDtoPerson(DateTime.Now, DateTime.Now)
                    }
                };

                var expected = new PersonerSvar
                {
                    Personer = source.Person.Select(GetDomenePerson).ToList()
                };

                //Act
                var result = DtoConverter.ToDomainObject(source);

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

                comparator.AreEqual(expected, result, out differences);
                Assert.Equal(0, differences.Count());
            }
Exemple #5
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 #6
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 #7
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);
            }
Exemple #8
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);
            }
        protected virtual bool IsValueChanged(string propertyName)
        {
            var prop         = DbEntry.Property(propertyName);
            var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType;

            object originalValue = OriginalValue(propertyName);
            object currentValue  = CurrentValue(propertyName);

            Comparator comparator = ComparatorFactory.GetComparator(propertyType);

            var changed = (StateOfEntity() == EntityState.Modified &&
                           prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue));

            if ((Type)propertyType == typeof(Byte[]) && changed)
            {
                if (!((IStructuralEquatable)originalValue).Equals(currentValue, StructuralComparisons.StructuralEqualityComparer))
                {
                    throw new Exception("EX_UltimaActualizacion");
                }
                else
                {
                    return(false);
                }
            }
            return(changed);
        }
        public void ComparatorAreEqual()
        {
            List <Tuple <Object, Object> > inputsAreEqual = new List <Tuple <Object, Object> >
            {
                new Tuple <Object, Object>(new ExampleClass(), new ExampleClass()),
                new Tuple <Object, Object>("This is my String.", "This is my String."),
                new Tuple <Object, Object>(1337, 1337),
                new Tuple <Object, Object>("1337", "1337"),
                new Tuple <Object, Object>(DateTime.MinValue, DateTime.MinValue),
                new Tuple <Object, Object>(DateTime.MinValue, DateTime.Parse("01/01/0001 00:00:00"))
            };

            foreach (Tuple <Object, Object> input in inputsAreEqual)
            {
                Assert.IsTrue(Comparator.AreEqual(input.Item1, input.Item2));
                Assert.IsTrue(Comparator.AreEqual(input.Item2, input.Item1));
            }

            List <Tuple <Object, Object> > inputAreNotEqual = new List <Tuple <Object, Object> >
            {
                new Tuple <Object, Object>(new ExampleClass(), new ExampleClass(1)),
                new Tuple <Object, Object>("This is my String.", "This is my string."),
                new Tuple <Object, Object>(1337, "1337"),
                new Tuple <Object, Object>("1337", 1337.0),
                new Tuple <Object, Object>(DateTime.MinValue, DateTime.Now)
            };

            foreach (Tuple <Object, Object> input in inputAreNotEqual)
            {
                Assert.IsFalse(Comparator.AreEqual(input.Item1, input.Item2));
                Assert.IsFalse(Comparator.AreEqual(input.Item2, input.Item1));
            }
        }
Exemple #11
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 #12
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 #13
0
            public void Converts_error_successfully()
            {
                //Arrange
                var source = new error
                {
                    errorcode    = "errorcode",
                    errormessage = "errormessage",
                    errortype    = "errortype"
                };

                var expected = new Error
                {
                    Code    = source.errorcode,
                    Message = source.errormessage,
                    Type    = source.errortype
                };

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

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

                compartor.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);
            }
        private IEnumerable <AuditLogDetail> CreateComplexTypeLogDetails(string propertyName)
        {
            NavigationEntry entryMember = DbEntry.Member(propertyName) as NavigationEntry;

            if (entryMember != null)
            {
                Type complexTypeObj = entryMember.CurrentValue.GetType();

                foreach (PropertyInfo pi in complexTypeObj.GetProperties())
                {
                    string complexTypePropertyName = $"{propertyName}_{pi.Name}";
                    object complexTypeOrigValue    = OriginalValue(propertyName);
                    object complexTypeNewValue     = CurrentValue(propertyName);

                    object origValue = complexTypeOrigValue == null ? null : pi.GetValue(complexTypeOrigValue);
                    object newValue  = complexTypeNewValue == null ? null : pi.GetValue(complexTypeNewValue);

                    Comparator comparator = ComparatorFactory.GetComparator(complexTypeObj);

                    if (!comparator.AreEqual(newValue, origValue))
                    {
                        yield return(new AuditLogDetail
                        {
                            PropertyName = complexTypePropertyName,
                            OriginalValue = origValue?.ToString(),
                            NewValue = newValue?.ToString(),
                            Log = _log
                        });
                    }
                }
            }
        }
            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);
            }
            public void Converts_direct_job_status_with_multiple_signers_successfully()
            {
                //Arrange
                var now = DateTime.Now;

                var source = new directsignaturejobstatusresponse
                {
                    signaturejobid     = 77,
                    reference          = null,
                    signaturejobstatus = directsignaturejobstatus.FAILED,
                    status             = new[]
                    {
                        new signerstatus {
                            signer = "12345678910", Value = "REJECTED", since = now
                        },
                        new signerstatus {
                            signer = "10987654321", Value = "SIGNED", since = now
                        }
                    },
                    xadesurl = new[]
                    {
                        new signerspecificurl {
                            signer = "10987654321", Value = "https://example.com/xades-url"
                        }
                    },
                    confirmationurl = "https://example.com/confirmation-url"
                };

                var nextPermittedPollTime = DateTime.Now;

                var expected = new JobStatusResponse(
                    source.signaturejobid,
                    source.reference,
                    JobStatus.Failed,
                    new JobReferences(new Uri("https://example.com/confirmation-url"), null),
                    new List <Signature>
                {
                    new Signature("12345678910", null, SignatureStatus.Rejected, now),
                    new Signature("10987654321", new XadesReference(new Uri("https://example.com/xades-url")), SignatureStatus.Signed, now)
                },
                    nextPermittedPollTime
                    );

                //Act
                var result = DataTransferObjectConverter.FromDataTransferObject(source, nextPermittedPollTime);

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

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Exemple #19
0
        protected override bool IsValueChanged(string propertyName)
        {
            var prop         = DbEntry.Property(propertyName);
            var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType;

            object originalValue = OriginalValue(propertyName);

            Comparator comparator = ComparatorFactory.GetComparator(propertyType);

            var changed = prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue);

            return(changed);
        }
        protected override bool IsValueChanged(string propertyName)
        {
            if (GlobalTrackingConfig.TrackEmptyPropertiesOnAdditionAndDeletion)
            {
                return(true);
            }

            var    propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType;
            object defaultValue = propertyType.DefaultValue();
            object currentValue = CurrentValue(propertyName);

            Comparator comparator = ComparatorFactory.GetComparator(propertyType);

            return(!comparator.AreEqual(defaultValue, currentValue));
        }
Exemple #21
0
            public void Converts_direct_job_successfully()
            {
                //Arrange
                const string pin         = "12345678910";
                const string redirectUrl = "https://api.signering.posten.no/redirect/#/c316e5b62df86a5d80e517b3ff4532738a9e7e43d4ae6075d427b1b58355bc63";
                const string signerUrl   = "https://api.signering.posten.no/api/123456789/direct/signature-jobs/1/signers/1";
                const string statusUrl   = "https://api.signering.posten.no/api/signature-jobs/1/status";
                var          source      = new directsignaturejobresponse
                {
                    signaturejobid = 1444,
                    reference      = "senders-reference",
                    redirecturl    = new[] { new signerspecificurl {
                                                 signer = pin, Value = redirectUrl
                                             } },
                    statusurl = statusUrl,
                    signer    = new[]
                    {
                        new directsignerresponse()
                        {
                            href            = signerUrl,
                            ItemElementName = ItemChoiceType1.personalidentificationnumber,
                            redirecturl     = redirectUrl,
                            Item            = pin,
                        },
                    }
                };

                var expected = new JobResponse(
                    source.signaturejobid,
                    source.reference,
                    new List <SignerResponse>()
                {
                    new SignerResponse(new PersonalIdentificationNumber(pin), new Uri(redirectUrl), NewRedirectUrlRequest.FromSignerUrl(new Uri(signerUrl)))
                },
                    new StatusUrl(new Uri(source.statusurl))
                    );

                //Act
                var actual = new JobResponse(source);

                //Assert
                var comparator = new Comparator();

                comparator.AreEqual(expected, actual, out var differences);
                Assert.Empty(differences);
            }
            public void Converts_signed_direct_job_status_successfully()
            {
                //Arrange
                var now = DateTime.Now;

                var source = new directsignaturejobstatusresponse
                {
                    signaturejobid     = 77,
                    reference          = "senders-reference",
                    signaturejobstatus = directsignaturejobstatus.COMPLETED_SUCCESSFULLY,
                    status             = new[] { new signerstatus {
                                                     signer = "12345678910", Value = "SIGNED", since = now
                                                 } },
                    confirmationurl = "http://signatureRoot.digipost.no/confirmation",
                    xadesurl        = new[] { new signerspecificurl {
                                                  signer = "12345678910", Value = "http://signatureRoot.digipost.no/xades"
                                              } },
                    padesurl = "http://signatureRoot.digipost.no/pades"
                };

                var nextPermittedPollTime = DateTime.Now;

                var expected = new JobStatusResponse(
                    source.signaturejobid,
                    source.reference,
                    JobStatus.CompletedSuccessfully,
                    new JobReferences(new Uri(source.confirmationurl), new Uri(source.padesurl)),
                    new List <Signature> {
                    new Signature("12345678910", new XadesReference(new Uri("http://signatureRoot.digipost.no/xades")), SignatureStatus.Signed, now)
                },
                    nextPermittedPollTime
                    );

                //Act
                var result = DataTransferObjectConverter.FromDataTransferObject(source, nextPermittedPollTime);

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

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
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);
            }
            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_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);
            }
            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 Convert_changes()
            {
                //Arrange
                const int personsCount = 10;

                var source = new HentEndringerRespons
                {
                    fraEndringsNummer     = 0,
                    tilEndringsNummer     = personsCount,
                    senesteEndringsNummer = personsCount
                };

                var persons = new List <Scripts.XsdToCode.Code.Person>();

                for (var i = 0; i < personsCount; i++)
                {
                    persons.Add(GetDtoPerson(DateTime.Now, DateTime.Now));
                }
                source.Person = persons.ToArray();

                var expected = new EndringerSvar
                {
                    FraEndringsNummer     = source.fraEndringsNummer,
                    SenesteEndringsNummer = source.senesteEndringsNummer,
                    TilEndringsNummer     = source.tilEndringsNummer,
                    Personer = source.Person.Select(GetDomenePerson).ToList()
                };

                //Act
                var result = DtoConverter.ToDomainObject(source);

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

                comparator.AreEqual(expected, result, out differences);
                Assert.Equal(0, differences.Count());
            }
Exemple #28
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);
            }
            public void ResponseContainerWithDecryptedResponse()
            {
                //Arrange
                var xmlResponse = XmlResource.Response.GetPerson();
                var bodyElement = xmlResponse.SelectSingleNode("/env:Envelope/env:Body", NamespaceManager.InitalizeNamespaceManager(xmlResponse));
                var expectedDeserializedResponse = SerializeUtil.Deserialize <HentPersonerRespons>(bodyElement.InnerXml);
                //Act
                var candidate = new ResponseContainer(GenerateStreamFromString(xmlResponse.OuterXml));

                //Assert
                var cmp = new Comparator();

                cmp.AreEqual(expectedDeserializedResponse, SerializeUtil.Deserialize <HentPersonerRespons>(candidate.BodyElement.InnerXml));
                Assert.NotNull(candidate.HeaderBinarySecurityToken);
                Assert.NotNull(candidate.BodyElement);
                Assert.NotNull(candidate.Cipher);
                Assert.NotNull(candidate.HeaderSecurityElement);
                Assert.NotNull(candidate.HeaderSignature);
                Assert.NotNull(candidate.HeaderSignatureElement);
                Assert.NotNull(candidate.TimestampElement);

                Assert.Null(candidate.EncryptedBody);
            }
Exemple #30
0
            public void Converts_portal_job_response_successfully()
            {
                //Arrange
                var signaturejobid      = 12345678910;
                var jobReference        = "senders-reference";
                var httpCancellationurl = "http://cancellationurl.no";
                var source = new portalsignaturejobresponse
                {
                    signaturejobid  = signaturejobid,
                    reference       = jobReference,
                    cancellationurl = httpCancellationurl
                };
                var expected = new JobResponse(signaturejobid, jobReference, new Uri(httpCancellationurl));

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

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

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