public async Task GetNewValueFetchFalse() { // Value is not in cache first. Event though we say no, it should still do the fetch. var dc = new dummyCache(); var rtn = await dc.GetAndFetchLatest("key", () => Observable.Return("hi there"), dt => Observable.Return(false)) .ToList() .Timeout(TimeSpan.FromMilliseconds(1000)) .FirstAsync(); // We should have gotten it back Assert.IsNotNull(rtn); Assert.AreEqual(1, rtn.Count); Assert.AreEqual("hi there", rtn[0]); // It should be in the cache. Assert.AreEqual("hi there", await dc.GetObject <string>("key")); }
public async Task FetchOnce() { // When not in cache, make sure it is fetched and updated in the cache. var ds = new dummyScreen(); var ms = new myMeetingListRef(); var dc = new dummyCache(); var t = new CategoryPageViewModel(ds, ms, dc); await TestUtils.SpinWait(() => dc.NumberTimesInsertCalled >= 1, 1000); var item = await dc.GetObject <IMeetingRefExtended[]>(ms.UniqueString); Assert.IsNotNull(item); Assert.AreEqual(2, item.Length); Assert.AreEqual("meeting1", item[0].Title); Assert.AreEqual("meeting2", item[1].Title); }