public void TestSetup() { request = Request.Get("http://foo/bar"); response = new Response(ResponseCode.Ok); parameters = RequestParameters.Empty.WithConnectionTimeout(1.Seconds()); var budget = Budget.WithRemaining(5.Seconds()); transport = Substitute.For <ITransport>(); transport.SendAsync(Arg.Any <Request>(), Arg.Any <TimeSpan?>(), Arg.Any <TimeSpan>(), Arg.Any <CancellationToken>()).ReturnsTask(_ => response); context = Substitute.For <IRequestContext>(); context.Request.Returns(_ => request); context.Budget.Returns(_ => budget); context.Transport.Returns(_ => transport); context.Parameters.Returns(_ => parameters); responseCriteria = new List <IResponseCriterion>(); responseClassifier = Substitute.For <IResponseClassifier>(); responseClassifier.Decide(Arg.Any <Response>(), Arg.Any <IList <IResponseCriterion> >()).Returns(ResponseVerdict.Accept); resultStatusSelector = Substitute.For <IClusterResultStatusSelector>(); resultStatusSelector.Select(null, null).ReturnsForAnyArgs(ClusterResultStatus.Success); module = new AbsoluteUrlSenderModule(responseClassifier, responseCriteria, resultStatusSelector); }
public void Setup() { request = Request.Get("http://foo/bar"); response = new Response(ResponseCode.Ok); var budget = Budget.WithRemaining(5.Seconds()); context = Substitute.For <IRequestContext>(); context.Request.Returns(_ => request); context.Budget.Returns(_ => budget); transport = Substitute.For <ITransport>(); transport.SendAsync(Arg.Any <Request>(), Arg.Any <TimeSpan>(), Arg.Any <CancellationToken>()).ReturnsTask(_ => response); responseCriteria = new List <IResponseCriterion>(); responseClassifier = Substitute.For <IResponseClassifier>(); responseClassifier.Decide(Arg.Any <Response>(), Arg.Any <IList <IResponseCriterion> >()).Returns(ResponseVerdict.Accept); resultStatusSelector = Substitute.For <IClusterResultStatusSelector>(); // ReSharper disable AssignNullToNotNullAttribute resultStatusSelector.Select(null, null).ReturnsForAnyArgs(ClusterResultStatus.Success); // ReSharper restore AssignNullToNotNullAttribute module = new AbsoluteUrlSenderModule(transport, responseClassifier, responseCriteria, resultStatusSelector); }