コード例 #1
0
        public void Execute_WhenCalledWithNoParameters_ShouldThrowException()
        {
            // Arrange
            const string response = "Test Response";

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

            // Assert
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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);
        }