public void SmsNotification()
            {
                //Arrange
                var atTimes = new List <DateTime> {
                    DateTime.Now, DateTime.Now.AddHours(3)
                };
                var afterHours = new List <int> {
                    4, 5
                };

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

                var expected = new SmsNotification();

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

                //Act
                var actual = SendDataTransferObjectConverter.FromDataTransferObject(sourceDto);

                //Assert
                Comparator.AssertEqual(expected, actual);
            }
            public void Document()
            {
                //Arrange
                var source = new document
                {
                    subject             = "testSubject",
                    filetype            = "txt",
                    authenticationlevel = authenticationlevel.PASSWORD,
                    sensitivitylevel    = sensitivitylevel.SENSITIVE,
                    smsnotification     = new smsnotification {
                        afterhours = new[] { 3 }
                    },
                    uuid        = "uuid",
                    contenthash = new contenthash {
                        hashalgorithm = "SHA256", Value = "5o0RMsXcgSZpGsL7FAmhSQnvGkqgOcvl5JDtMhXBSlc="
                    }
                };

                IDocument expected = new Document(source.subject, source.filetype, AuthenticationLevel.Password, SensitivityLevel.Sensitive, new SmsNotification(3))
                {
                    ContentHash = new ContentHash {
                        HashAlgoritm = source.contenthash.hashalgorithm, Value = source.contenthash.Value
                    },
                    Guid = source.uuid
                };

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

                //Assert
                Comparator.AssertEqual(expected, actual);
            }
示例#3
0
        public async Task <IMessageDeliveryResult> SendMessageAsync(IMessage message, bool skipMetaDataValidation = false)
        {
            _logger.LogDebug($"Outgoing Digipost message to Recipient: {message.DigipostRecipient}");

            var uri = new Uri("messages", UriKind.Relative);

            var messageDeliveryResultTask = RequestHelper.PostMessage <messagedelivery>(message, uri, skipMetaDataValidation);

            if (messageDeliveryResultTask.IsFaulted && messageDeliveryResultTask.Exception != null)
            {
                throw messageDeliveryResultTask.Exception?.InnerException;
            }

            var messageDeliveryResult = SendDataTransferObjectConverter.FromDataTransferObject(await messageDeliveryResultTask.ConfigureAwait(false));

            _logger.LogDebug($"Response received for message to recipient, {message.DigipostRecipient}: '{messageDeliveryResult.Status}'. Will be available to Recipient at {messageDeliveryResult.DeliveryTime}.");

            return(messageDeliveryResult);
        }
            public void Message()
            {
                //Arrange
                var deliverytime = DateTime.Now.AddDays(3);

                var source = new messagedelivery
                {
                    primarydocument = new document
                    {
                        subject             = "TestSubject",
                        filetype            = "txt",
                        authenticationlevel = authenticationlevel.TWO_FACTOR,
                        sensitivitylevel    = sensitivitylevel.SENSITIVE,
                        uuid        = "uuid",
                        contenthash = new contenthash {
                            hashalgorithm = "SHA256", Value = "5o0RMsXcgSZpGsL7FAmhSQnvGkqgOcvl5JDtMhXBSlc="
                        }
                    },
                    attachment = new[]
                    {
                        new document
                        {
                            subject             = "TestSubject Attachment",
                            filetype            = "txt",
                            authenticationlevel = authenticationlevel.TWO_FACTOR,
                            sensitivitylevel    = sensitivitylevel.SENSITIVE,
                            uuid        = "attachmentGuid",
                            contenthash = new contenthash {
                                hashalgorithm = "SHA256", Value = "5o0RMsXcgSZpGsL7FAmhSQnvGkqgOcvl5JDtMhXBSlc="
                            }
                        }
                    },
                    deliverytime          = deliverytime,
                    deliverymethod        = channel.DIGIPOST,
                    deliverytimeSpecified = true,
                    status   = messagestatus.DELIVERED,
                    senderid = 123456
                };

                var expected = new MessageDeliveryResult
                {
                    PrimaryDocument = new Document(source.primarydocument.subject, source.primarydocument.filetype, AuthenticationLevel.TwoFactor, SensitivityLevel.Sensitive)
                    {
                        Guid        = source.primarydocument.uuid,
                        ContentHash = new ContentHash {
                            HashAlgoritm = source.primarydocument.contenthash.hashalgorithm, Value = source.primarydocument.contenthash.Value
                        }
                    },
                    Attachments = new List <Document>
                    {
                        new Document(source.attachment[0].subject, source.attachment[0].filetype, AuthenticationLevel.TwoFactor, SensitivityLevel.Sensitive)
                        {
                            Guid        = source.attachment[0].uuid,
                            ContentHash = new ContentHash {
                                HashAlgoritm = source.attachment[0].contenthash.hashalgorithm, Value = source.attachment[0].contenthash.Value
                            }
                        }
                    },
                    DeliveryTime   = source.deliverytime,
                    DeliveryMethod = DeliveryMethod.Digipost,
                    Status         = MessageStatus.Delivered,
                    SenderId       = source.senderid
                };

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

                //Assert
                Comparator.AssertEqual(expected, actual);
            }