Exemple #1
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();
        }
Exemple #2
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();
        }
Exemple #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();
        }
Exemple #4
0
        public async Task Subscription_ValuePatch_ShouldUpdateCache()
        {
            // Arrange
            var peopleToUpdate = new PeopleMap();
            var updatedPeople  = new PeopleMap();

            peopleToUpdate["rreddings"] = new Person("Joey Tribbiani", 31, "How you doin'?");

            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["rreddings"].ToJson(), peopleToUpdate["rreddings"].ToJson());
            Assert.AreEqual(updatedPeople.Count, 8);

            // Teardown
            valueSub.Stop();
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            PeopleMap.Map(modelBuilder, AppSettings.UnitTest);
            UsersMap.Map(modelBuilder, AppSettings.UnitTest);
            UsersProvidersMap.Map(modelBuilder, AppSettings.UnitTest);
            UsersRolesMap.Map(modelBuilder, AppSettings.UnitTest);
            UsersTokensMap.Map(modelBuilder, AppSettings.UnitTest);

            ConfigsMap.Map(modelBuilder, AppSettings.UnitTest);
        }
Exemple #6
0
        public async Task Update_ShouldUpdateValue()
        {
            // Arrange
            var people = new PeopleMap();

            people["rreddings"] = new Person("Joey Tribbiani", 31, "How you doin'?");

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

            // Assert
            var actual = await Database.Ref("People")
                         .Once <PeopleMap>();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Count, 8);
        }
        /*public void ValidateXML(string schemaFileName, string xmlFileName)
        {
            var schemas = new XmlSchemaSet();
            schemas.Add("", schemaFileName);

            Console.WriteLine("Attempting to validate {0}", xmlFileName);
            var xmlDoc = XDocument.Load(xmlFileName);
            bool errors = false;
            xmlDoc.Validate(schemas, (o, e) =>
            {
                Console.WriteLine("{0}", e.Message);
                errors = true;
            });
            Console.WriteLine("{0}: {1}", xmlFileName, errors ? "did not validate" : "validated");
            Console.WriteLine();

            IEnumerable<XElement> people =
                from seg in xmlDoc.Descendants()
                where (string)seg.Element("ClassName") == "TMan"
                select seg;

            int c = people.Count(); // 46 + 92 = 138
            foreach( var el in people)
            {
                Console.WriteLine( el.Element("Color").Value );
            }

            Console.WriteLine();
        }*/

        public PeopleMap LoadPeopleXML( string fileName )
        {
            var result = new PeopleMap();
            var serializer = new XmlSerializer(typeof(PeopleTypes.TBuilding));
            var reader = new FileStream(fileName, FileMode.Open);
            var building = serializer.Deserialize(reader) as PeopleTypes.TBuilding;
            foreach (var floor in building.FloorList)
            {
                var peopleList = new List<PeopleTypes.TMan>();
                foreach (var man in floor.People)
                {
                    peopleList.Add(man);
                }

                result.Add(floor.Number, peopleList);
            }
            return result;
        }