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);
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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();
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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();
            }
        }