Beispiel #1
0
            public void ReturnsDecodedResponse()
            {
                var decoder = Mock.Of <TransactMessageResponseDecoder>();

                Mock.Get(decoder)
                .Setup(x => x.Decode(It.IsAny <string>(), It.IsAny <string>()))
                .Returns(new TransactMessageResponse()
                {
                    TransactionId = "123"
                });

                var silverpop = Mock.Of <ISilverpopCommunicationsClient>();

                Mock.Get(silverpop)
                .Setup(x => x.SftpDownload(It.IsAny <string>()))
                .Returns(new MemoryStream());

                var response = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, decoder: decoder, silverpopFactory: () => silverpop)
                               .GetStatusOfMessageBatch("file.xml.gz.status");

                Assert.Equal("123", response.TransactionId);
            }
Beispiel #2
0
            public void PerformsSftpMove()
            {
                var silverpop = Mock.Of <ISilverpopCommunicationsClient>();

                var filename = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, silverpopFactory: () => silverpop)
                               .SendMessageBatch(new TransactMessage()
                {
                    Recipients = TransactClientTests.TestRecipients
                })
                               .Single();

                // Moq.Sequences has a dependency on NUnit.
                // Rather than installing it to verify upload occurs before move
                // simply assuming the operations occur in the correct order.

                Mock.Get(silverpop)
                .Verify(
                    x => x.SftpMove(
                        "transact/temp/" + GetUploadedFilenameFromStatusFilename(filename),
                        "transact/inbound/" + GetUploadedFilenameFromStatusFilename(filename)),
                    Times.Once());
            }
Beispiel #3
0
            public void PerformsOperationsInBatches()
            {
                var encoder = Mock.Of <TransactMessageEncoder>();

                var filename = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, encoder: encoder)
                               .SendMessageBatch(new TransactMessage()
                {
                    Recipients = TransactClientTests.TestRecipientsTwoBatches
                });

                Mock.Get(encoder)
                .Verify(
                    x => x.Encode(It.IsAny <TransactMessage>()),
                    Times.Exactly(2));
            }
Beispiel #4
0
            public void ReturnsDecodedResponse()
            {
                var decoder = Mock.Of <TransactMessageResponseDecoder>();

                Mock.Get(decoder)
                .Setup(x => x.Decode(It.IsAny <string>(), It.IsAny <string>()))
                .Returns(new TransactMessageResponse()
                {
                    TransactionId = "123"
                });

                var response = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, decoder: decoder).SendMessage(new TransactMessage());

                Assert.Equal("123", response.TransactionId);
            }
Beispiel #5
0
            public void ReturnsExpectedTrackingFilenames()
            {
                var filenames = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                })
                                .SendMessageBatch(new TransactMessage()
                {
                    Recipients = TransactClientTests.TestRecipientsTwoBatches
                });

                Guid.Parse(filenames.First().Substring(0, GuidCharCount));
                Assert.True(filenames.First().EndsWith(".1.xml.gz.status"));

                Guid.Parse(filenames.Last().Substring(0, GuidCharCount));
                Assert.True(filenames.Last().EndsWith(".2.xml.gz.status"));

                Assert.Equal(2, filenames.Count());
            }
Beispiel #6
0
            public void PerformsSftpUpload()
            {
                var silverpop = Mock.Of <ISilverpopCommunicationsClient>();

                var filename = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, silverpopFactory: () => silverpop)
                               .SendMessageBatch(new TransactMessage()
                {
                    Recipients = TransactClientTests.TestRecipients
                })
                               .Single();

                Mock.Get(silverpop)
                .Verify(
                    x => x.SftpGzipUpload(
                        It.IsAny <string>(),
                        "transact/temp/" + GetUploadedFilenameFromStatusFilename(filename)),
                    Times.Once());
            }
            public void ReturnsDecodedResponse()
            {
                var decoder = Mock.Of<TransactMessageResponseDecoder>();
                Mock.Get(decoder)
                    .Setup(x => x.Decode(It.IsAny<string>()))
                    .Returns(new TransactMessageResponse()
                    {
                        TransactionId = "123"
                    });

                var silverpop = Mock.Of<ISilverpopCommunicationsClient>();
                Mock.Get(silverpop)
                    .Setup(x => x.SftpDownload(It.IsAny<string>()))
                    .Returns(new MemoryStream());

                var response = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, decoder: decoder, silverpopFactory: () => silverpop)
                .GetStatusOfMessageBatch("file.xml.gz.status");

                Assert.Equal("123", response.TransactionId);
            }
            public void PerformsOperationsInBatches()
            {
                var encoder = Mock.Of<TransactMessageEncoder>();

                var filename = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, encoder: encoder)
                .SendMessageBatch(new TransactMessage() { Recipients = TransactClientTests.TestRecipientsTwoBatches });

                Mock.Get(encoder)
                    .Verify(
                        x => x.Encode(It.IsAny<TransactMessage>()),
                        Times.Exactly(2));
            }
            public void PerformsSftpMove()
            {
                var silverpop = Mock.Of<ISilverpopCommunicationsClient>();

                var filename = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, silverpopFactory: () => silverpop)
                .SendMessageBatch(new TransactMessage() { Recipients = TransactClientTests.TestRecipients })
                .Single();

                // Moq.Sequences has a dependency on NUnit.
                // Rather than installing it to verify upload occurs before move
                // simply assuming the operations occur in the correct order.

                Mock.Get(silverpop)
                    .Verify(
                        x => x.SftpMove(
                            "transact/temp/" + GetUploadedFilenameFromStatusFilename(filename),
                            "transact/inbound/" + GetUploadedFilenameFromStatusFilename(filename)),
                        Times.Once());
            }
            public void PerformsSftpUpload()
            {
                var silverpop = Mock.Of<ISilverpopCommunicationsClient>();

                var filename = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, silverpopFactory: () => silverpop)
                .SendMessageBatch(new TransactMessage() { Recipients = TransactClientTests.TestRecipients })
                .Single();

                Mock.Get(silverpop)
                    .Verify(
                        x => x.SftpGzipUpload(
                            It.IsAny<string>(),
                            "transact/temp/" + GetUploadedFilenameFromStatusFilename(filename)),
                        Times.Once());
            }
            public void ReturnsExpectedTrackingFilenames()
            {
                var filenames = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                })
                .SendMessageBatch(new TransactMessage() { Recipients = TransactClientTests.TestRecipientsTwoBatches });

                Guid.Parse(filenames.First().Substring(0, GuidCharCount));
                Assert.True(filenames.First().EndsWith(".1.xml.gz.status"));

                Guid.Parse(filenames.Last().Substring(0, GuidCharCount));
                Assert.True(filenames.Last().EndsWith(".2.xml.gz.status"));

                Assert.Equal(2, filenames.Count());
            }
            public void ReturnsDecodedResponse()
            {
                var decoder = Mock.Of<TransactMessageResponseDecoder>();
                Mock.Get(decoder)
                    .Setup(x => x.Decode(It.IsAny<string>()))
                    .Returns(new TransactMessageResponse()
                    {
                        TransactionId = "123"
                    });

                var response = new TransactClientTester(configuration: new TransactClientConfiguration()
                {
                    PodNumber = 0
                }, decoder: decoder).SendMessage(new TransactMessage());

                Assert.Equal("123", response.TransactionId);
            }