Exemplo n.º 1
0
            public async void CallsOnNextWhenNewDataIsPersisted(HttpMethods method, string url, bool expectedResult)
            {
                var oldRequest = new HttpRequest(HttpMethods.Get, "http://localhost:3000/good");

                var sqlite = new Mock<ISQLiteAsyncConnection>();
                sqlite.Setup(s => s.Get<HttpRequest>()).Returns(Task.FromResult(new List<HttpRequest> { oldRequest }));

                var newRequest = new HttpRequest(method, url);
                var requestHistory = new RequestHistory(sqlite.Object);

                // if onnext is not called by the time the timeout happens, then call OnException.
                Observable.Timeout(requestHistory.GetRequestsObservable(), TimeSpan.FromSeconds(2))
                    .Subscribe(
                        _ => Assert.True(expectedResult),
                        ex => Assert.False(expectedResult));

                await requestHistory.AddRequestAsync(newRequest);
            }