Beispiel #1
0
        public void WritesLargeMessagesToStorage()
        {
            // Arrange
            var WriteAsyncAsyncWasCalled = false;
            var mockFileRepo             = new Mock <IFileRepository>();
            var testLargeMessage         = new string('a', 66000);

            testAzureQueue =
                new Infrastructure.Storage.MessageQueues.AzureQueue(testConnectionString, testQueueName, mockFileRepo.Object);

            mockFileRepo.Setup(f => f.WriteAsync(It.IsAny <string>(), It.IsAny <byte[]>()))
            .Callback(
                (string filePath, byte[] data) =>
            {
                // Assert
                Assert.IsTrue(filePath.StartsWith("LargeQueueFiles\\LogEventUnitTests\\"),
                              "Expected large filepath to match");
                Assert.IsTrue(filePath.EndsWith(".json"), "Expected large filepath to be a json file");

                Assert.AreEqual(testLargeMessage, Encoding.UTF8.GetString(data),
                                "Expected large message to be the same");

                WriteAsyncAsyncWasCalled = true;
            })
            .Returns(Task.CompletedTask);

            // Act (We expect an exception here because we cant actually connect to azure so we get a connection error)
            Assert.ThrowsAsync <FormatException>(async() => await testAzureQueue.AddMessageAsync(testLargeMessage));

            // Assert
            Assert.IsTrue(WriteAsyncAsyncWasCalled, "Expected IFileRepository.WriteAsyncAsync to be called.");
        }
Beispiel #2
0
 public void BeforeEach()
 {
     testAzureQueue = new Infrastructure.Storage.MessageQueues.AzureQueue(testConnectionString, testQueueName);
 }