public void Execute_WhenCalledWithNoParameters_ShouldThrowException()
        {
            // Arrange
            const string response = "Test Response";

            // Act
            JsonResponseParserFactory target = new JsonResponseParserFactory();
            target.Handle(null, response);

            // Assert
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="randomService"><see cref="IRandomService"/> to use to get random values.  Defaults to <see cref="RandomOrgApiService"/></param>
        public UsageMethod(IRandomService randomService = null)
        {
            _randomService = randomService ?? new RandomOrgApiService();

            // We need to keep this separate so we can retrieve the list of values that are returned from to the caller
            _responseParser = new JsonResponseParserFactory(new UsageResponseParser());

            _responseHandlerFactory = new ResponseHandlerFactory(
                new ErrorHandlerThrowException(new ErrorParser()),
                _responseParser
            );
        }
        public void Execute_WhenCanParseReturnsFalse_ShouldThrowException()
        {
            // Arrange
            const string response = "Test Response";
            Mock<IParameters> parameters = new Mock<IParameters>();

            Mock<IResponseParser> responseHandlerMock = new Mock<IResponseParser>();
            responseHandlerMock.Setup(m => m.CanParse(parameters.Object)).Returns(false);

            // Act
            JsonResponseParserFactory target = new JsonResponseParserFactory(responseHandlerMock.Object);
            target.Handle(parameters.Object, response);

            // Assert
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="advisoryDelayHandler">
        /// Class which handles the apprioriate delay before the request is called.
        /// It is required that this class be passed into the method because the same instance of the <see cref="AdvisoryDelayHandler"/> must be passed in on every request.
        /// </param>
        /// <param name="randomService"><see cref="IRandomService"/> to use to get random values.  Defaults to <see cref="RandomOrgApiService"/></param>
        public UuidBasicMethod(AdvisoryDelayHandler advisoryDelayHandler, IRandomService randomService = null)
        {
            RandomService = randomService ?? new RandomOrgApiService();
            RequestBuilder = new JsonRequestBuilder(new UuidJsonRequestBuilder());

            BeforeRequestCommandFactory = new BeforeRequestCommandFactory(advisoryDelayHandler);

            // We need to keep this separate so we can retrieve the list of values that are returned from to the caller
            ResponseParser = new JsonResponseParserFactory(new UuidResponseParser());

            ResponseHandlerFactory = new ResponseHandlerFactory(
                new ErrorHandlerThrowException(new ErrorParser()),
                advisoryDelayHandler,
                new VerifyIdResponseHandler(),
                ResponseParser
            );
        }
        public void Execute_WhenParseCalled_ShouldSetResponseInfoToMock()
        {
            // Arrange
            const string response = "Test Response";
            Mock<IParameters> parameters = new Mock<IParameters>();
            Mock<IResponseInfo> responseInfoMock = new Mock<IResponseInfo>();

            Mock<IResponseParser> responseHandlerMock = new Mock<IResponseParser>();
            responseHandlerMock.Setup(m => m.CanParse(parameters.Object)).Returns(true);
            responseHandlerMock.Setup(m => m.Parse(response)).Returns(responseInfoMock.Object);

            // Act
            JsonResponseParserFactory target = new JsonResponseParserFactory(responseHandlerMock.Object);
            target.Handle(parameters.Object, response);

            // Assert
            target.ResponseInfo.Should().Equal(responseInfoMock.Object);
        }
        public void GetHandler_WhenCalled_ShouldReturnTrue()
        {
            // Arrange
            Mock<IParameters> parameters = new Mock<IParameters>();
            Mock<IResponseParser> responseHandlerMock = new Mock<IResponseParser>();

            // Act
            JsonResponseParserFactory target = new JsonResponseParserFactory(responseHandlerMock.Object);
            var actual = target.CanHandle(parameters.Object);

            // Assert
            actual.Should().Be.True();
        }