public void Execute_WhenCalledWithNoParameters_ShouldThrowException() { // Arrange const string response = "Test Response"; // Act JsonResponseParserFactory target = new JsonResponseParserFactory(); target.Handle(null, response); // Assert }
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 }
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); }