public void TestInvoke_RemoteConnection_NextInvokeNotCalled() { bool isNextCalled = false; var next = new Microsoft.Owin.Fakes.StubOwinMiddleware(null) { InvokeIOwinContext = c => new Task(() => isNextCalled = true) }; var mw = new NoRemoteConnectionMiddleware(next); var ctx = new Microsoft.Owin.Fakes.StubIOwinContext(); var request = new Microsoft.Owin.Fakes.StubIOwinRequest(); request.RemoteIpAddressGet = () => "10.1.1.1"; ctx.RequestGet = () => request; mw.Invoke(ctx).Wait(); Assert.IsFalse(isNextCalled); }
public void TestInvoke_LocalConnection_NextInvokCalled() { bool isNextCalled = false; var next = new Microsoft.Owin.Fakes.StubOwinMiddleware(null) { #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously InvokeIOwinContext = async(c) => isNextCalled = true #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously }; var mw = new NoRemoteConnectionMiddleware(next); var ctx = new Microsoft.Owin.Fakes.StubIOwinContext(); var request = new Microsoft.Owin.Fakes.StubIOwinRequest(); request.RemoteIpAddressGet = () => "127.0.0.1"; ctx.RequestGet = () => request; mw.Invoke(ctx).Wait(); Assert.IsTrue(isNextCalled); }