Beispiel #1
0
        public void LookupByCuisineTest()
        {
            Ingredient a    = new Ingredient("name1", "description1", 123, "gr");
            Ingredient b    = new Ingredient("name2", "description2", 456, "kg");
            Recipe     food = new Recipe(
                "kabab",
                "charkh karde",
                new Ingredient[] { a },
                3,
                "irani",
                new string[] { "irani", "kabab" }
                );
            Recipe food1 = new Recipe(
                "joje",
                "kabab karde",
                new Ingredient[] { b },
                2,
                "irani",
                new string[] { "irani", "joje" }
                );
            RecipeBook book = new RecipeBook("recipeBook", 2);

            book.Add(food);
            book.Add(food1);
            Assert.IsTrue(new Recipe[] { food, food1 }.SequenceEqual(book.LookupByCuisine("irani")));
        }
Beispiel #2
0
        public void DeserializeTest()
        {
            Ingredient ing;

            ing = new Ingredient("name", "desc", 6.0, "kg");
            List <Ingredient> ings = new List <Ingredient>();

            ings.Add(ing);
            Recipe recipetest;
            Recipe recipetest2;

            recipetest = new Recipe("recipetitle", "use with water", ings, 1, "iranian", new string[] { "iran", "food" });
            recipetest.IngredientCount = 1;
            RecipeBook reBook;

            reBook = new RecipeBook("rebook", 1);
            reBook.Add(recipetest);
            using (StreamWriter writer = new StreamWriter(@"recipse.txt"))
            {
                recipetest.Serialize(writer, @"ing3.txt");
            }
            using (StreamReader reader = new StreamReader(@"recipse.txt"))
            {
                recipetest2 = Recipe.Deserialize(reader, @"recipse.txt", @"ing3.txt");
            }
            //Assert.AreEqual(recipetest.Cuisine, recipetest2.Cuisine);
        }
Beispiel #3
0
        public void RecipeBookTest()
        {
            RecipeBook book = new RecipeBook("recipeBook", 10);

            Assert.AreEqual("recipeBook", book.TempTitle);
            Assert.AreEqual(10, book.TempCapacity);
        }
Beispiel #4
0
 public void AddRecipe()
 {
     RecipeBook.AddRecipe(NewRecipe);
     SelectedRecipe  = NewRecipe;
     SelectedRecipes = new ObservableCollection <Recipe>(RecipeBook.Recipes.Where(r => r.Type.Name == SelectedRecipe.Type.Name));
     NewRecipe       = new Recipe();
 }
Beispiel #5
0
        public void LookupByTitleTest()
        {
            Ingredient a    = new Ingredient("name1", "description1", 123, "gr");
            Ingredient b    = new Ingredient("name2", "description2", 456, "kg");
            Recipe     food = new Recipe(
                "kabab",
                "charkh karde",
                new Ingredient[] { a },
                3,
                "irani",
                new string[] { "irani", "kabab" }
                );
            Recipe food1 = new Recipe(
                "joje",
                "kabab karde",
                new Ingredient[] { b },
                2,
                "irani",
                new string[] { "irani", "joje" }
                );
            RecipeBook book = new RecipeBook("recipeBook", 2);

            book.Add(food);
            book.Add(food1);
            Assert.AreEqual(food, book.LookupByTitle(food.Title));
        }
Beispiel #6
0
        public void resetRecipe(int userID, int recipeID)
        {
            var oldr       = _context.Recipe.Find(recipeID);
            var recipebook = _context.RecipeBook.Find(oldr.recipeID, userID);

            if (recipebook != null)
            {
                _context.RecipeBook.Remove(recipebook);
                _context.SaveChanges();
            }
            if (oldr.original != -1)
            {
                cleanNotOriginalRecipe(oldr.recipeID);
                UserRecipe ur = _context.UserRecipe.Find(recipeID, userID);
                if (ur != null)
                {
                    _context.UserRecipe.Remove(ur);
                    _context.SaveChanges();
                }
                _context.Recipe.Remove(oldr);
                _context.SaveChanges();
            }
            RecipeBook rb    = new RecipeBook(oldr.original, userID);
            var        rbori = _context.RecipeBook.Find(oldr.original, userID);

            if (rbori == null)
            {
                _context.RecipeBook.Add(rb);
                _context.SaveChanges();
            }
        }
Beispiel #7
0
    public InteractableObject getResult()
    {
        realignProcess();
        potentialRecipe = getRecipe();
        if (potentialRecipe != null)
        {
            if (!checkFor(potentialRecipe, recipesKnown))
            {
                RecipeBook r = getRecipebook();
                if (r != null)
                {
                    r.recipes.Add(potentialRecipe);
                    recipesKnown.Add(potentialRecipe);
                }
                else
                {
                    recipesKnown.Add(potentialRecipe);
                }
            }
            resultState = 2;
            return(potentialRecipe.product);
        }

        resultState = 3;
        return(null);
    }
Beispiel #8
0
        public void RemoveByTitleTest()
        {
            RecipeBook        recipeBook = new RecipeBook("reBook", 2);
            Ingredient        ing        = new Ingredient("name", "desc", 2.5, "kg");
            List <Ingredient> ings2      = new List <Ingredient>();

            ings2.Add(ing);
            Recipe recipe = new Recipe("title", "instructions", ings2, 3, "cuisine", new string[] { "keywords", "iranian" });

            recipeBook.Add(recipe);
            using (StreamWriter writer = new StreamWriter(@"reader4.txt"))
            {
                var a = Console.Out;
                Console.SetOut(writer);
                Console.WriteLine("title");
                Console.SetOut(a);
            }

            using (StreamReader reader = new StreamReader(@"reader4.txt"))
            {
                Console.SetIn(reader);
                Recipe recipeTitle = Program.RemoveByTitle(recipeBook);
                Assert.AreEqual(recipeTitle.Title, "title");
            }
        }
Beispiel #9
0
        public void ShouldServerJuice_WhenJuiceIsSelected()
        {
            RecipeBook recipeBook = new RecipeBook(_consoleWriter);

            recipeBook.MakeRecipe("juice");
            Debug.Assert(_consoleWriter.GetOutputBuffer() == "Here you go! Fresh and nice juice.");
        }
Beispiel #10
0
        public void RemoveByKeywordTest()
        {
            RecipeBook        recipeBook = new RecipeBook("reBook", 2);
            Ingredient        ing        = new Ingredient("name", "desc", 2.5, "kg");
            Ingredient        ing1       = new Ingredient("name1", "desc1", 21.5, "kg");
            List <Ingredient> ings2      = new List <Ingredient>();

            ings2.Add(ing);
            ings2.Add(ing1);
            Recipe recipe = new Recipe("title", "instructions", ings2, 3, "cuisine", new string[] { "title", "iranian" });

            recipeBook.Add(recipe);
            recipeBook.Add(recipe);
            using (StreamWriter writer = new StreamWriter(@"reader5.txt"))
            {
                var a = Console.Out;
                Console.SetOut(writer);
                Console.WriteLine("title");
                Console.SetOut(a);
            }
            using (StreamReader reader = new StreamReader(@"reader5.txt"))
            {
                Console.SetIn(reader);
                Recipe[] recipeKeyword = Program.RemoveByKeyword(recipeBook);
                for (int i = 0; i < recipeKeyword.Length && recipeKeyword[i] != null; i++)
                {
                    Assert.AreEqual(recipeKeyword[i].Title, "title");
                }
            }
        }
        public static async Task <RecipeBook> AddRecipeBook(RecipeBook recipeBook)
        {
            var           dbHandler     = new CoffeeBookDbHandlerFactory().GetDbHandler();
            RecipeBookDto recipeBookDto = ConvertFromRecipeBook(recipeBook);

            return(ConvertToRecipeBook(await dbHandler.AddRecipeBookAsync(recipeBookDto)));
        }
Beispiel #12
0
        private void EditRecipeBook(RecipeBook recipeBook)
        {
            PropertiesTitle       = "Edit Recipe Book";
            PropertiesName        = recipeBook.Name == null ? "" : recipeBook.Name;
            PropertiesDescription = recipeBook.Description == null ? "" : recipeBook.Description;

            List <string> rs = new List <string>();

            foreach (Recipe r in recipes)
            {
                rs.Add(r.Name);
            }

            if (recipeBook.Recipes != null && recipeBook.Recipes.Count > 0)
            {
                rs.Insert(0, "");
                foreach (var r in recipeBook.Recipes)
                {
                    rs.Remove(r.Name);
                    rs.Insert(0, r.Name);
                }
            }

            PropertiesRecipes         = rs;
            ShowPropertiesDescription = true;
            ShowPropertiesRecipes     = true;
            ShowPropertiesCoffees     = false;
            IsPropertiesRecipeBook    = true;
            IsPropertiesRecipe        = false;
            IsPropertiesCoffee        = false;
        }
Beispiel #13
0
        public void RecipeBookTest()
        {
            RecipeBook recipeBook1 = new RecipeBook("the title", 1);

            Assert.AreEqual(recipeBook1.Title, "the title");
            Assert.AreEqual(recipeBook1.Capacity, 1);
        }
Beispiel #14
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            List <Tag> selectedTags = new List <Tag>();

            foreach (Object obj in TagDisplayer.SelectedItems)
            {
                selectedTags.Add((Tag)obj);
            }

            List <Ingredient> selectedIngredients = new List <Ingredient>();

            foreach (Object obj in IngredientDisplayer.SelectedItems)
            {
                selectedIngredients.Add((Ingredient)obj);
            }

            Recipe     r    = new Recipe(selectedTags, selectedIngredients, TitleEntryTB.Text, DirectionsEntryTB.Text, NotesEntryTB.Text);
            RecipeBook book = RecipeBook.Instance;

            book.Recipes.Add(r);
            rv.ListBox_RecipeView.ItemsSource = null;
            rv.ListBox_RecipeView.ItemsSource = book.Recipes;
            this.Close();
            RecipeBook.Instance.Recipes.Sort();
        }
    public void CraftWeapon()
    {
        var rolls = System.Enum.GetValues(typeof(Roll));

        weapon.Roll = (Roll)rolls.GetValue(Random.Range(0, rolls.Length));

        Globals.GetPlayerController().WeaponData = weapon;

        var playerResources = Globals.GetPlayerController().resources;

        ResourceType[] resourcesNeeded = recipe.resources.Keys.ToArray();

        for (int i = 0; i < resourcesNeeded.Length; i++)
        {
            playerResources[resourcesNeeded[i]] -= recipe.resources[resourcesNeeded[i]];
        }

        GameObject text = Instantiate(Globals.GetPlayerController().Text, Globals.GetPlayer().transform.position, Quaternion.identity) as GameObject;

        text.transform.SetParent(GameObject.Find("OverlayCanvas").transform);
        text.GetComponent <Text>().color = Color.white;
        string rollName = ("" + Globals.GetPlayerController().WeaponData.Roll).Equals("None") ? "" : ("" + Globals.GetPlayerController().WeaponData.Roll);

        text.GetComponent <Text>().text          = rollName + " " + Globals.GetPlayerController().WeaponData.Type + " T" + Globals.GetPlayerController().WeaponData.Tier;
        text.GetComponent <DestroyAfter>().after = 3.0f;
        text.GetComponent <MoveUp>().speed       = 0.005f;

        RecipeBook.GetInstance().gameObject.SetActive(false);
    }
Beispiel #16
0
        public void RemoveTest()
        {
            Ingredient a    = new Ingredient("name1", "description1", 123, "gr");
            Ingredient b    = new Ingredient("name2", "description2", 456, "kg");
            Recipe     food = new Recipe(
                "kabab",
                "charkh karde",
                new Ingredient[] { a },
                3,
                "irani",
                new string[] { "irani", "kabab" }
                );
            Recipe food1 = new Recipe(
                "joje",
                "kabab karde",
                new Ingredient[] { b },
                2,
                "irani",
                new string[] { "irani", "joje" }
                );
            RecipeBook book = new RecipeBook("recipeBook", 1);

            book.Add(food);
            Assert.IsTrue(book.Remove("kabab"));
            Assert.IsFalse(book.Remove("joje"));
        }
Beispiel #17
0
        private void SetBookActive(RecipeBook book)
        {
            activeBook = Program.ApplicationContext.Book;

            srcImages.DataSource          = activeBook.Images;
            srcBaseIngredients.DataSource = activeBook.Ingredients;
            srcProduct.DataSource         = activeBook.Products;
        }
Beispiel #18
0
    void Start()
    {
        // Create a new recipe book.
        recipeBook = new RecipeBook();

        // Get the food object from the index provided.
        foodObject = recipeBook.foodItems[foodIndex];
    }
Beispiel #19
0
    //----------------Trial Code, Need To Get This Somehow To Get My Code To Work-------------------------------------------------
    public void RequestOrderTrial(RecipeBook a, int b, int c)
    {//If We Have 2 ThemeDays At Some Point, Like Green Day And A BurthDay Where A Woman Can Buy A Cake Or Just Plain Salad
        _recipeBook       = a;
        _multiOrderAmount = b;
        _multiOrderChance = c;

        RequestOrder();
    }
Beispiel #20
0
        private void saveRecipeBook(string folderLocation, RecipeBook currentBook)
        {
            string       file   = folderLocation + "/" + inventoryFile;
            StreamWriter writer = new StreamWriter(file);
            Stream       stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None);

            formatter.Serialize(stream, currentBook);
        }
Beispiel #21
0
        public void DeserializeDonuts_LargeNested()
        {
            // Act
            RecipeBook book = JsonSerializer.ReadObject <RecipeBook>(Properties.Resources.donuts_json);

            // Assert
            AssertDonuts(book);
        }
Beispiel #22
0
    private void Start()
    {
        // Creating new recipe book.
        recipeBook = new RecipeBook();

        // Gets the food type of the crate object.
        crateFood = recipeBook.foodItems[crateObject.GetComponent <FoodBehaviour>().foodIndex];
    }
Beispiel #23
0
        private RecipeBook loadBook(String folderLocation)
        {
            string     file   = System.IO.Path.Combine(folderLocation, recipeBookFile);
            Stream     stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
            RecipeBook p      = (RecipeBook)formatter.Deserialize(stream);

            stream.Close();
            return(p);
        }
Beispiel #24
0
        public void ShouldNotServerBeer_WhenClientIsBelow18()
        {
            RecipeBook recipeBook = new RecipeBook(_consoleWriter);

            _consoleWriter.SetInputBuffer("17");
            recipeBook.MakeRecipe("beer");

            Debug.Assert(_consoleWriter.GetOutputBuffer() == "Sorry but are not older to order a beer.");
        }
Beispiel #25
0
        public void ShouldNotInvokeAnyMethod_WhenInputIsInvalid(string input)
        {
            RecipeBook recipeBook = new RecipeBook(_consoleWriter);

            _consoleWriter.SetInputBuffer(input);
            recipeBook.MakeRecipe("beer");

            Debug.Assert(_consoleWriter.GetOutputBuffer() == "Input not valid");
        }
Beispiel #26
0
        public void ShouldServerBeer_WhenClientIsAbove18()
        {
            RecipeBook recipeBook = new RecipeBook(_consoleWriter);

            _consoleWriter.SetInputBuffer("20");
            recipeBook.MakeRecipe("beer");

            Debug.Assert(_consoleWriter.GetOutputBuffer() == "Here you go! Cold beer.");
        }
Beispiel #27
0
        public RecipeBook LoadRecipeBook()
        {
            var blockTypes = Load <ItemType>("*Items.json").OrderBy(item => item.Name);
            var recipes    = Load <Recipe>("*Recipes.json").OrderBy(rec => rec.Result.Type.Name);
            var book       = new RecipeBook(blockTypes, recipes);

            ValidateRecipeBook(book);
            return(book);
        }
Beispiel #28
0
        public void ShouldReturnTrue_WhenGetAllDrinks()
        {
            RecipeBook recipeBook = new RecipeBook(_consoleWriter);

            foreach (var d in drinksList)
            {
                Debug.Assert(recipeBook.GetAvailableDrinkNames().Contains(d));
            }
        }
Beispiel #29
0
        public CalculatorPage()
        {
            InitializeComponent();

            var item = RecipeBook.GetRecipe(RecipeNames.ModularFrame);

            viewModel      = new CalculatorViewModel(item);
            BindingContext = viewModel;
        }
Beispiel #30
0
    // Class Constructor
    public Request(Recipe recipe, int time, GameObject requestObject)
    {
        this.recipeBook    = new RecipeBook();
        this.recipe        = recipe;
        this.time          = time;
        this.timeLeft      = time;
        this.requestObject = requestObject;

        SetUp();
    }
 public DrinksCabinet( RecipeBook recipes )
 {
     this.recipes = recipes;
 }
 public void Start()
 {
     recipes = new LocalRecipeBook();
 }