public void Execute_WhenNoCommands_ShouldReturnTrue() { // Arrange Mock<IParameters> parameters = new Mock<IParameters>(); // Act BeforeRequestCommandFactory target = new BeforeRequestCommandFactory(); var actual = target.Execute(parameters.Object); // Assert actual.Should().Be.True(); }
/// <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 StringSignedMethod(AdvisoryDelayHandler advisoryDelayHandler, IRandomService randomService = null) : base(advisoryDelayHandler, randomService) { var verifySignatureHandler = new VerifySignatureHandler(RandomService); BeforeRequestCommandFactory = new BeforeRequestCommandFactory(advisoryDelayHandler, verifySignatureHandler); ResponseHandlerFactory = new ResponseHandlerFactory( new ErrorHandlerThrowException(new ErrorParser()), verifySignatureHandler, advisoryDelayHandler, new VerifyIdResponseHandler(), ResponseParser ); }
/// <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 BlobSignedMethod(AdvisoryDelayHandler advisoryDelayHandler, IRandomService randomService = null) : base(advisoryDelayHandler, randomService) { // We just need to setup the Verification Signature class, other than that everything else is the same. var verifySignatureHandler = new VerifySignatureHandler(RandomService); BeforeRequestCommandFactory = new BeforeRequestCommandFactory(advisoryDelayHandler, verifySignatureHandler); ResponseHandlerFactory = new ResponseHandlerFactory( new ErrorHandlerThrowException(new ErrorParser()), verifySignatureHandler, advisoryDelayHandler, new VerifyIdResponseHandler(), ResponseParser ); }
public void Execute_WhenCanHandleReturnsFalse_ShouldReturnTrue() { // Arrange Mock<IParameters> parameters = new Mock<IParameters>(); Mock<IRequestCommand> requestBuilderMock = new Mock<IRequestCommand>(); requestBuilderMock.Setup(m => m.CanProcess(parameters.Object)).Returns(false); // Act BeforeRequestCommandFactory target = new BeforeRequestCommandFactory(requestBuilderMock.Object); var actual = target.Execute(parameters.Object); // Assert actual.Should().Be.True(); requestBuilderMock.Verify(m => m.Process(parameters.Object), Times.Never); requestBuilderMock.Verify(m => m.CanProcess(parameters.Object), Times.Once); }