Пример #1
0
        public async Task SyncNewRecordsfromCloud()
        {
            var mockhttpclientUtil        = new Mock <IHttpClientUtil>();
            HttpUtilityOutput httpUtility = new HttpUtilityOutput();
            List <Notes>      lstNotes    = new List <Notes>();
            Notes             client1Note = new Notes();

            client1Note.NoteGuid  = "b68f9b83-667c-43f3-98ca-422b31ad37b5";
            client1Note.Title     = "Title1";
            client1Note.Body      = new StringBuilder("TestBody");
            client1Note.IsDeleted = false;
            lstNotes.Add(client1Note);
            var json = JsonConvert.SerializeObject(lstNotes);

            httpUtility.Status  = HttpStatusCode.OK;
            httpUtility.Content = json;
            mockhttpclientUtil.Setup(m => m.PostHttpAsync(It.IsAny <Uri>(), It.IsAny <String>())).ReturnsAsync(httpUtility);

            NotesSync notesSync = new NotesSync(mockhttpclientUtil.Object);
            Dictionary <string, Notes> resultDic = await notesSync.Sync("TestClient1").ConfigureAwait(false);

            Assert.IsTrue(resultDic.ContainsKey(client1Note.NoteGuid));
        }
Пример #2
0
 private static void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     Dictionary <string, Notes> dictNotes = new NotesSync(new HttpClientUtil()).Sync(clientId).Result;
 }