Ejemplo n.º 1
0
            public void ShouldClearResultBuildersSendMessagesAndTheCurrentBuilder()
            {
                var mockResultBuilder = new Mock <IResultBuilder>();
                var mrh = new MessageResponseHandler();

                // Two messages are queued, as one will be popped off when handling a success message.
                mrh.Register(new PullAllMessage(), mockResultBuilder.Object);
                mrh.Register(new PullAllMessage(), mockResultBuilder.Object);
                // We need to handle the success message to et the CurrentResultBuilder
                mrh.HandleSuccessMessage(new Dictionary <string, object> {
                    { "fields", new List <object> {
                          "x"
                      } }
                });

                mrh.SentMessages.Should().HaveCount(1);
                mrh.ResultBuilders.Should().HaveCount(1);
                mrh.CurrentResultBuilder.Should().NotBeNull();

                mrh.Clear();

                mrh.SentMessages.Should().HaveCount(0);
                mrh.ResultBuilders.Should().HaveCount(0);
                mrh.CurrentResultBuilder.Should().BeNull();
            }
            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();
            }