public async void Set() { var todo = new Todo { name = "Execute SET", priority = 2 }; var response = await _client.SetAsync("todos/set", todo); var result = response.ResultAs<Todo>(); Assert.NotNull(response); Assert.AreEqual(todo.name, result.name); }
public async void PushAsync() { var todo = new Todo { name = "Execute PUSH4", priority = 2 }; var response = await _client.PushAsync("todos/push/pushAsync", todo); Assert.NotNull(response); Assert.NotNull(response.Result); Assert.NotNull(response.Result.Name); /*Returns pushed data name like -J8LR7PDCdz_i9H41kf7*/ Console.WriteLine(response.Result.Name); }
public async void SetAsync() { var todo = new Todo { name = "Execute SET", priority = 2 }; var response = await _client.SetAsync("todos/setAsync", todo); var result = response.ResultAs<Todo>(); Assert.NotNull(response); Assert.AreEqual(todo.name, result.name); // overwrite the todo we just set response = await _client.SetAsync("todos", todo); var getResponse = await _client.GetAsync("/todos/setAsync"); result = getResponse.ResultAs<Todo>(); Assert.Null(result); }
protected override void FinalizeSetUp() { _expected = new Todo { name = "Do your homework!", priority = 1 }; _firebaseRequestManagerMock = MockFor<IRequestManager>(); _expectedResponse = new HttpResponseMessage { Content = new StringContent(_expected.ToJson()), StatusCode = HttpStatusCode.OK }; _failureResponse = new HttpResponseMessage { Content = new StringContent("error"), StatusCode = HttpStatusCode.InternalServerError }; _firebaseClient = new FirebaseClient(_firebaseRequestManagerMock.Object); }
public async void OnChangeGetAsync() { var expected = new Todo { name = "Execute PUSH4GET1", priority = 2 }; var changes = 0; var observer = _client.OnChangeGetAsync<Todo>("fakepath/OnGetAsync/", (events, arg) => { Interlocked.Increment(ref changes); Assert.NotNull(arg); Assert.AreEqual(expected.name, arg.name); }); await _client.SetAsync("fakepath/OnGetAsync/", expected); Thread.Sleep(4000); await _client.SetAsync("fakepath/OnGetAsync/name", "PUSH4GET1"); Thread.Sleep(4000); Assert.AreEqual(2, changes); observer.Result.Cancel(); }
public void Update() { _client.Set("todos/updatetest/set", new Todo { name = "Execute SET", priority = 2 }); var todoToUpdate = new Todo { name = "Execute UPDATE!", priority = 1 }; var response = _client.Update("todos/updatetest/set", todoToUpdate); Assert.NotNull(response); var actual = response.ResultAs<Todo>(); Assert.AreEqual(todoToUpdate.name, actual.name); Assert.AreEqual(todoToUpdate.priority, actual.priority); }
public async void UpdateAsync() { await _client.SetAsync("todos/set/setAsync", new Todo { name = "Execute SET", priority = 2 }); var todoToUpdate = new Todo { name = "Execute UPDATE!", priority = 1 }; var response = await _client.UpdateAsync("todos/set/setAsync", todoToUpdate); Assert.NotNull(response); var actual = response.ResultAs<Todo>(); Assert.AreEqual(todoToUpdate.name, actual.name); Assert.AreEqual(todoToUpdate.priority, actual.priority); }
public async void OnChangeGetAsync() { var expected = new Todo { name = "Execute PUSH4GET1", priority = 2 }; var changes = 0; var observer = _client.OnChangeGetAsync<Todo>("fakepath/OnGetAsync/", (events, arg) => { Interlocked.Increment(ref changes); Assert.NotNull(arg); Assert.AreEqual(expected.name, arg.name); }); await _client.SetAsync("fakepath/OnGetAsync/", expected); await Task.Delay(2000); await _client.SetAsync("fakepath/OnGetAsync/name", "PUSH4GET1"); await Task.Delay(2000); try { if (changes == 3) { Assert.Inconclusive(); } Assert.AreEqual(2, changes); } finally { observer.Result.Cancel(); } }