public async Task UpdateNoChange() { // Setup the first and second request. var f = new FileInfo("1020448.json"); AutoWebAccess.AddUriResponse("http://inspirehep.net:80/record/1020448?ln=en&of=recjson", f); int count = 0; using (var cs = new InSpireContactStore()) { // Watch for updates. Since no change, we should see only one. cs.ContactUpdateStream.Subscribe(u => { count++; }); // Add. var c = GetInspireSimpleContact(f) as InSpireContact; cs.Add(c); // Trigger the update. await cs.Update(); } Assert.AreEqual(1, count); }
public async Task UpdateLastName() { // Setup the first and second request. var f = new FileInfo("1020448.json"); AutoWebAccess.AddUriResponse("http://inspirehep.net:80/record/1020448?ln=en&of=recjson", f); int count = 0; int updates = 0; using (var cs = new InSpireContactStore()) { // Watch for updates. Since no change, we should see only one. cs.ContactUpdateStream.Subscribe(u => { count++; if (u._reason == ContactTrackerLib.Database.ContactDB.UpdateReason.Update) { Assert.AreEqual("Last Name", u._updateReasonText); updates++; } }); // Add. var c = GetInspireSimpleContact(f) as InSpireContact; c.LastName = "Mable"; cs.Add(c); // Trigger the update. await cs.Update(); } Assert.AreEqual(2, count); Assert.AreEqual(1, updates); }
public async Task FindPaperUrlAsName() { AutoWebAccess.AddUriResponse("http://inspirehep.net:80/record/1518295?of=recjson", new FileInfo("1518295.json")); // A paper can't be re-read as an actual person just yet. var f = new InSpireContactFinder(); var info = (await f.FindContactAsync(new Uri("http://inspirehep.net/record/1518295"))) .ToArray(); }
public async Task InSpireFindGoodURLDW() { AutoWebAccess.AddUriResponse("http://inspirehep.net:80/record/1020448?ln=en&of=recjson", new FileInfo("1020448.json")); var finder = new InSpireContactFinder(); var info = (await finder.FindContactAsync(new Uri("http://inspirehep.net/record/1020448?ln=en"))) .ToArray(); Assert.AreEqual(1, info.Length); Assert.AreEqual("Daniel O.", info[0].FirstName); Assert.AreEqual("Whiteson", info[0].LastName); }
public void TestClean() { MEFComposer.Reset(); AutoWebAccess.Reset(); }
public void TestInit() { MEFComposer.Reset(); AutoWebAccess.Reset(); MEFComposer.AddObject(typeof(AutoWebAccess)); }