public void ShouldNoNPEIfCurrentResultBuilderIsNull() { var mrh = new MessageResponseHandler(); mrh.EnqueueMessage(new PullAllMessage()); mrh.HandleFailureMessage("code.error", "message"); }
public void ShouldCreateDatabaseExceptionWhenClassificationContainsDatabaseError(string code) { var mockResultBuilder = new Mock <IMessageResponseCollector>(); var mrh = new MessageResponseHandler(); mrh.EnqueueMessage(new PullAllMessage(), mockResultBuilder.Object); mrh.HandleFailureMessage(code, "message"); mrh.HasError.Should().BeTrue(); mrh.Error.Should().BeOfType <DatabaseException>(); }
public void ShouldCallDoneFailureIfCurrentResultBuilderNotNull() { var mockResultBuilder = new Mock <IMessageResponseCollector>(); var mrh = new MessageResponseHandler(); mrh.EnqueueMessage(new PullAllMessage(), mockResultBuilder.Object); mrh.HandleFailureMessage("code.error", "message"); mockResultBuilder.Verify(x => x.DoneFailure(), Times.Once); }
public void ShouldCreateTransientExceptionWhenClassificationContainsTransientError(string code) { var mockResultBuilder = new Mock <IResultBuilder>(); var mrh = new MessageResponseHandler(); mrh.Register(new PullAllMessage(), mockResultBuilder.Object); mrh.HandleFailureMessage(code, "message"); mrh.HasError.Should().BeTrue(); mrh.Error.Should().BeOfType <TransientException>(); }
public void LogsTheMessageToDebug() { var mockResultBuilder = new Mock <IMessageResponseCollector>(); var mockLogger = new Mock <ILogger>(); var mrh = new MessageResponseHandler(mockLogger.Object); mrh.EnqueueMessage(new PullAllMessage(), mockResultBuilder.Object); mrh.HandleFailureMessage("code.error", "message"); mockLogger.Verify(x => x.Debug(It.Is <string>(actual => actual.StartsWith("S: ")), It.Is <object[]>(actual => actual.First() is FailureMessage)), Times.Once); }
public void DequeuesFromSentMessagesAndSetsCurrentBuilder() { var mockResultBuilder = new Mock <IMessageResponseCollector>(); var mrh = new MessageResponseHandler(); mrh.EnqueueMessage(new PullAllMessage(), mockResultBuilder.Object); mrh.SentMessages.Should().HaveCount(1); mrh.CurrentResponseCollector.Should().BeNull(); mrh.HandleFailureMessage("code.error", "message"); mrh.SentMessages.Should().HaveCount(0); mrh.CurrentResponseCollector.Should().NotBeNull(); }
public void ShouldClearErrorState() { var mockResultBuilder = new Mock <IResultBuilder>(); var mrh = new MessageResponseHandler(); mrh.Register(new PullAllMessage(), mockResultBuilder.Object); mrh.HandleFailureMessage("Neo.ClientError.General.ReadOnly", "message"); mrh.HasError.Should().BeTrue(); mrh.Error.Should().BeOfType <ClientException>(); mrh.Clear(); mrh.HasError.Should().BeFalse(); mrh.Error.Should().BeNull(); }
public void ShouldSuccessMessageNotClearErrorState() { var mrh = new MessageResponseHandler(); mrh.EnqueueMessage(new PullAllMessage()); mrh.EnqueueMessage(new PullAllMessage()); mrh.HandleFailureMessage("Neo.ClientError.General.ReadOnly", "message"); mrh.HasError.Should().BeTrue(); mrh.Error.Should().BeOfType <ClientException>(); mrh.HandleSuccessMessage(new Dictionary <string, object> { { "fields", new List <object> { "x" } } }); mrh.HasError.Should().BeTrue(); mrh.Error.Should().NotBeNull(); }
public void HandleFailureMessage(string code, string message) { FailureMessageCalled++; _messageHandler.HandleFailureMessage(code, message); }