コード例 #1
0
        private async Task TestExecutionException(
            Func <IAgentExceptionHandler, Task <MessagingContext> > act,
            Action <string> assertLocation)
        {
            // Arrange
            var sut = new PullSendAgentExceptionHandler(GetDataStoreContext, StubConfig.Default, new InMemoryMessageBodyStore());

            // Act
            await act(sut);

            // Assert
            GetDataStoreContext.AssertOutException(
                ex =>
            {
                Assert.True(ex.Exception.IndexOf(_expectedMessage, StringComparison.CurrentCultureIgnoreCase) > -1);
                assertLocation(ex.MessageLocation);
            });
        }
コード例 #2
0
        public async Task InsertInException_IfHandlingTransformException()
        {
            // Arrange
            byte[] expectedBody = Encoding.UTF8.GetBytes("serialize me!");

            using (var bodyStore = new InMemoryMessageBodyStore())
                using (var stream = new MemoryStream(expectedBody))
                {
                    var sut = new PullSendAgentExceptionHandler(GetDataStoreContext, StubConfig.Default, bodyStore);

                    // Act
                    await sut.HandleTransformationException(
                        new Exception(_expectedMessage),
                        new ReceivedMessage(stream));
                }
            // Assert
            GetDataStoreContext.AssertOutException(
                ex =>
            {
                Assert.NotNull(ex);
                Assert.Equal(_expectedMessage, ex.Exception);
            });
        }