예제 #1
0
        public async Task Subscription_PatchValueThatIsCurrentlyNullInChild_ShouldUpdateCache()
        {
            // Arrange
            var peopleToUpdate = new PeopleMap();
            var updatedPeople  = new PeopleMap();

            peopleToUpdate["rreddings"] = null;

            Semaphore semaphore = new Semaphore(0, 3);

            Action <PeopleMap> onValue = (PeopleMap people) =>
            {
                updatedPeople = people;
                semaphore.Release();
            };

            var valueSub = Database.Ref("People").OnValue(onValue);

            // Act
            var update = new Dictionary <string, string>();

            update["Motto"] = "Hi m8";
            await Database.Ref("People").Child("undefinedperson").Update(update);

            // Assert
            WaitFor(2, semaphore);
            Assert.AreEqual(updatedPeople.Count, 9);
            Assert.IsTrue(updatedPeople.ContainsKey("undefinedperson"));
            Assert.AreEqual(updatedPeople["undefinedperson"].Motto, "Hi m8");

            // Teardown
            valueSub.Stop();
        }
예제 #2
0
        public async Task Subscription_PatchNullValueInChild_ShouldUpdateCache()
        {
            // Arrange
            var       updatedPeople = new PeopleMap();
            Semaphore semaphore     = new Semaphore(0, 2);

            Action <PeopleMap> onValue = (PeopleMap people) =>
            {
                updatedPeople = people;
                semaphore.Release();
            };

            var valueSub = Database.Ref("People").OnValue(onValue);

            // Act
            var update = new Dictionary <string, string>();

            update["Motto"] = null;
            await Database.Ref("People").Child("rreddings").Update(update);

            // Assert
            WaitFor(2, semaphore);
            Assert.AreEqual(updatedPeople.Count, 8);
            Assert.IsTrue(updatedPeople.ContainsKey("rreddings"));
            Assert.IsNull(updatedPeople["rreddings"].Motto);

            // Teardown
            valueSub.Stop();
        }
예제 #3
0
        public async Task Subscription_ValuePatchNull_ShouldUpdateCache()
        {
            // Arrange
            var peopleToUpdate = new PeopleMap();
            var updatedPeople  = new PeopleMap();

            peopleToUpdate["rreddings"] = null;

            Semaphore semaphore = new Semaphore(0, 2);

            Action <PeopleMap> onValue = (PeopleMap people) =>
            {
                updatedPeople = people;
                semaphore.Release();
            };

            var valueSub = Database.Ref("People").OnValue(onValue);

            // Act
            await Database.Ref("People").Update(peopleToUpdate);

            // Assert
            WaitFor(2, semaphore);
            Assert.AreEqual(updatedPeople.Count, 7);
            Assert.IsFalse(updatedPeople.ContainsKey("rreddings"));

            // Teardown
            valueSub.Stop();
        }