public static void Main(string[] args) { Gimme.Register(new AsyncResourceProvider()); Gimme.Register(new SyncResourceProvider()); Gimme.Register(new ObservableResourceProvider()); int done = 0; //var ob = Gimme.Fetch<Thing>("Resource", new List<string> { "Resource 1", "Resource 2", "Resource 3", "Resource 4", "Resource 5" }); //ob.Subscribe(x => Console.WriteLine(x.Text), () => done++); var empty = Gimme.Fetch <Thing>("Invalid", null); empty.Subscribe(x => Console.WriteLine("this shouldn't happen"), () => { Console.WriteLine("Empty subscription worked."); done++; }); while (done < 2) { System.Threading.Thread.Sleep(500); Console.WriteLine("Doing some processing..."); } }
public async Task Sync_AsyncFetchNone() { var called = 0; await Gimme.Fetch <string>("Sync", new List <string>(), x => { Assert.Fail(); called++; }); Assert.AreEqual(0, called); }
public async Task Sync_AsyncFetchSimple() { var called = 0; await Gimme.Fetch <string>("Sync", new List <string> { "One" }, x => { Assert.AreEqual("One", x); called++; }); Assert.AreEqual(1, called); }
public async Task Sync_ObservableFetchSimple() { var called = 0; var completed = false; var ob = Gimme.Fetch <string>("Sync", new List <string> { "One" }); ob.Subscribe(x => { called++; Assert.AreEqual("One", x); }, () => completed = true); await ob.ToTask(); Assert.AreEqual(1, called); Assert.IsTrue(completed); }
public async Task Sync_ObservableFetchNotFound() { var called = 0; var completed = false; var ob = Gimme.Fetch <string>("Sync", new List <string> { "Missing" }); ob.Subscribe(x => { Assert.Fail(); called++; }, () => completed = true); try { await ob.ToTask(); Assert.Fail(); } catch (InvalidOperationException) { } Assert.AreEqual(0, called); Assert.IsTrue(completed); completed = false; ob = Gimme.Fetch <string>("Invalid", new List <string> { "One" }); ob.Subscribe(x => { Assert.Fail(); called++; }, () => completed = true); try { await ob.ToTask(); Assert.Fail(); } catch (InvalidOperationException) { } Assert.AreEqual(0, called); Assert.IsTrue(completed); }
public async Task Sync_AsyncFetchNotFound() { var called = 0; await Gimme.Fetch <string>("Sync", new List <string> { "Missing" }, x => { Assert.Fail(); called++; }); await Gimme.Fetch <string>("Invalid", new List <string> { "One" }, x => { Assert.Fail(); called++; }); Assert.AreEqual(0, called); }
public async Task Observable_ObservableFetchNone() { var called = 0; var completed = false; var ob = Gimme.Fetch <string>("Observable", new List <string>()); ob.Subscribe(x => { called++; Assert.Fail(); }, () => completed = true); try { await ob.ToTask(); Assert.Fail(); } catch (InvalidOperationException) { } Assert.AreEqual(0, called); Assert.IsTrue(completed); }