Esempio n. 1
0
        public MockModelerDBLoader(string filename)
        {
            var doc = XDocument.Load(filename);

            _dsRecipes = (from r in doc.Descendants("Recipe")
                          select new RecipeBinding()
            {
                Id = new Guid(r.Attribute("Id").Value),
                Rating = Convert.ToByte(r.Attribute("Rating").Value),
                Tags = RecipeTags.Parse(r.Attribute("Tags").Value)
            }).ToArray();

            _dsIngredients = (from u in doc.Descendants("Usage")
                              select new IngredientBinding()
            {
                RecipeId = new Guid(u.Attribute("RecipeId").Value),
                IngredientId = new Guid(u.Attribute("IngredientId").Value),
                Qty = Convert.ToSingle(u.Attribute("Qty").Value),
                Unit = Unit.Parse <Units>(u.Attribute("Unit").Value)
            }).ToArray();

            _dsRatings = (from r in doc.Descendants("Rating")
                          select new RatingBinding()
            {
                UserId = new Guid(r.Attribute("UserId").Value),
                RecipeId = new Guid(r.Attribute("RecipeId").Value),
                Rating = Convert.ToByte(r.Attribute("Rating").Value)
            }).ToArray();
        }
Esempio n. 2
0
        public void TestParsing()
        {
            var tags = RecipeTags.Parse("No Red Meat, Dinner, Lunch");

            Assert.AreEqual(3, tags.Length);
            Assert.AreEqual("NoRedMeat, Dinner, Lunch", tags.ToString());
        }
Esempio n. 3
0
        public void TestParsing()
        {
            RecipeTag dinner = "Dinner";
            RecipeTag lunch  = "Lunch";

            Assert.AreEqual(RecipeTag.Dinner, dinner);
            Assert.AreEqual(RecipeTag.Lunch, lunch);

            string strDinner = RecipeTag.Dinner;
            string strLunch  = RecipeTag.Lunch;

            Assert.AreEqual("Dinner", strDinner);
            Assert.AreEqual("Lunch", strLunch);

            var tags = RecipeTags.Parse("No Red Meat, Dinner, Lunch");

            Assert.AreEqual(3, tags.Length);
            Assert.AreEqual("No Red Meat, Dinner, Lunch", tags.ToString());
        }