private static IPreRequestPlugin CreatePreRequestPlugin(int order) { IPreRequestPlugin plugin = Substitute.For <IPreRequestPlugin>(); plugin.Order.Returns(order); plugin.Process(null).ReturnsForAnyArgs((IResponseData)null); return(plugin); }
public async Task OnBeforeRequestShouldReturnTheReturnedRepsonse() { IResponseData response = Substitute.For <IResponseData>(); IPreRequestPlugin plugin = CreatePreRequestPlugin(1); plugin.Process(this.request).Returns(response); this.bootstrapper.GetBeforeRequestPlugins().Returns(new[] { plugin }); IResponseData result = await this.processor.OnBeforeRequest(this.request); Assert.That(result, Is.SameAs(response)); }
public async Task OnBeforeRequestShouldInvokeThePluginsInTheCorrectOrder() { IPreRequestPlugin one = CreatePreRequestPlugin(1); IPreRequestPlugin two = CreatePreRequestPlugin(2); IPreRequestPlugin three = CreatePreRequestPlugin(3); this.bootstrapper.GetBeforeRequestPlugins().Returns(new[] { three, one, two }); await this.processor.OnBeforeRequest(this.request); Received.InOrder(() => { one.Process(this.request); two.Process(this.request); three.Process(this.request); }); }