public void Results_HasCorrectModelType_Food() { ViewResult resultsView = new FoodController().Results(1, 2, "Apple") as ViewResult; var result = resultsView.ViewData.Model; Assert.IsInstanceOfType(result, typeof(List <Food>)); }
public void UpdateForm_ReturnsCorrectView_True() { FoodController controller = new FoodController(); ActionResult updateView = controller.UpdateForm(1); Assert.IsInstanceOfType(updateView, typeof(ViewResult)); }
public void All_ReturnsCorrectView_True() { FoodController controller = new FoodController(); ActionResult allView = controller.All(); Assert.IsInstanceOfType(allView, typeof(ViewResult)); }
public void Search_ReturnsCorrectView_True() { FoodController controller = new FoodController(); ActionResult searchView = controller.Search(); Assert.IsInstanceOfType(searchView, typeof(ViewResult)); }
public void Add_ReturnsCorrectView_True() { FoodController controller = new FoodController(); ActionResult addView = controller.Add(1, "apple"); Assert.IsInstanceOfType(addView, typeof(RedirectToActionResult)); }
public FoodControllerTests() { _mocks = new MockRepository(MockBehavior.Default); _data = _mocks.Create <FoodDataRepository>(); _controller = new FoodController(_data.Object); }
public IEnumerator NewFood() { yield return(null); if (!GameObject.FindGameObjectWithTag("Food 1")) { GameObject food1 = Instantiate(FoodPrefab, foodOneLocation, transform.rotation); FoodController foodController1 = food1.GetComponentInChildren <FoodController>(); foodController1.gameManager = this; food1.tag = "Food 1"; yield return(new WaitForSeconds(0.3f)); } if (!GameObject.FindGameObjectWithTag("Food 2")) { GameObject food2 = Instantiate(FoodPrefab, foodTwoLocation, transform.rotation); FoodController foodController2 = food2.GetComponentInChildren <FoodController>(); foodController2.gameManager = this; food2.tag = "Food 2"; yield return(new WaitForSeconds(0.3f)); } if (!GameObject.FindGameObjectWithTag("Food 3")) { GameObject food3 = Instantiate(FoodPrefab, foodThreeLocation, transform.rotation); FoodController foodController3 = food3.GetComponentInChildren <FoodController>(); foodController3.gameManager = this; food3.tag = "Food 3"; } }
public void UpdateFoods(List <FoodData> listFood) { for (int idx = 0; idx < listFood.Count; idx++) { FoodData data = listFood[idx]; int fIdx = registeredFood.FindIndex(x => x.foodId.Equals(data.foodID)); //Find the given data in the list. If it's not in the list, create new food for the data if (fIdx < 0) { GameObject go = foodPool.GetGameObject(data.foodKeyword); FoodController control = go.GetComponent <FoodController>(); if (control == null) { control = go.AddComponent <FoodController>(); } LayerController.Instance.SetFoodLayer(go); go.gameObject.tag = "Food"; control.SetData(data); registeredFood.Add(control); } //When it's already in the list, just reset the data else { //registeredFood[fIdx].SetData(data); } } ClearFood(listFood); }
public HomeV2() { InitializeComponent(); button6.Enabled = false; button6.BackColor = Color.White; button6.ForeColor = Color.Black; updateTable(); listView1.Columns.Add("Tên", 200); listView1.Columns.Add("Giá", 100); listView1.View = View.Details; updateFood(-1); listView2.Columns.Add("Loại", 200); listView2.View = View.Details; updateCategory(); listFood = FoodController.getController().getListFood(); comboBox1.DataSource = listFood; comboBox1.SelectedIndex = -1; listView3.Columns.Add("Danh sách đã đặt", 200); listView3.Columns.Add("Số lượng", 100); listView3.View = View.Details; }
public void InsertTest() { Nutrient n = new Nutrient { Name = "Omega-3", Amount = 9000, Number = 1234, UnitName = "ug" }; List <Nutrient> nutrients = new List <Nutrient>(); nutrients.Add(n); // Arrange MealController controllerm = new MealController(); // Act List <Meal> loadAllM = controllerm.Get() as List <Meal>; //grab first result Meal meal = loadAllM[0]; Food f = new Food { FDCId = 999999, dataType = "test", description = "test", publicationDate = System.DateTime.Now, foodCode = "test", foodNutrients = nutrients, Quantity = 2, MealId = meal.Id }; // Arrange FoodController controller = new FoodController(); // Act int result = controller.Post(f); // Assert Assert.IsTrue(result > 0); }
private void button1_Click(object sender, EventArgs e) { if (rtbPrice.Text.Trim() == "" || rtbName.Text.Trim() == "") { MessageBox.Show("Tên và giá không được để trống"); return; } Food food = new Food(); food.FoodName = rtbName.Text.Trim(); food.Price = int.Parse(rtbPrice.Text.Trim()); food.Category = int.Parse(cbType.SelectedValue.ToString()); if (FoodController.getController().Exist(food)) { if (FoodController.getController().Add(food)) { MessageBox.Show("Thêm thành công"); rtbName.Text = ""; rtbPrice.Text = ""; } } else { MessageBox.Show("Đã tồn tại"); return; } }
public List <BFoodCategory> GetAllFoodCat2() { FoodController foodController = new FoodController(); List <BFoodCategory> foundCats = foodController.GetAllFoodCat2(); return(foundCats); }
/// <summary> /// /// Метод который реализует игровое поведение змеи /// /// </summary> /// <param name="culture"> Регион пользователя </param> /// <param name="resourceMenager"> Ресурсы для отображения сообщений пользователю </param> private static void GameProcess(WallController wallController, SnakeControllers snakeControllers, FoodController foodController, ResourceManager resourceMenager, CultureInfo culture) { while (!IsGameOver(wallController, snakeControllers)) { if (IsEatingSnake(snakeControllers, foodController)) { Point food = (Point)((ICreated)foodController).CreatedGameObject(); DrawGameObject(food); } else { MoveGameObject(snakeControllers); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(true); snakeControllers.HandleKey(key.Key); } } WriteGameOver(resourceMenager, culture); }
public void InsertTest() { // Arrange UserController controlleru = new UserController(); // Act List <User> loadAllU = controlleru.Get() as List <User>; //grab first result User u = loadAllU[0]; // Arrange FoodController controllerf = new FoodController(); // Act List <Food> loadAllF = controllerf.Get() as List <Food>; Meal m = new Meal { UserId = u.Id, Description = "Breakfast", FoodItems = loadAllF, Time = System.DateTime.Now }; // Arrange MealController controller = new MealController(); // Act int result = controller.Post(m); // Assert Assert.IsTrue(result > 0); }
// Use this for initialization void Start() { // GameObject cityStall = GameObject.Find("city_stall"); cam = Camera.main; m_foodController = GameObject.Find("FoodController").GetComponent <FoodController>(); m_manaController = GameObject.Find("ManaController").GetComponent <ManaController>(); }
public void CrashAndBurn() { FoodController foodSpawner = GameObject.Find("Food").GetComponent <FoodController>() as FoodController; // each tail link spawns a food foreach (Transform trans in tail) { Vector2 scatterPos = new Vector2(Random.Range(-scatterFactor, scatterFactor), Random.Range(-scatterFactor, scatterFactor)); Vector2 tailPos = trans.position; foodSpawner.MakeFood(tailPos + scatterPos); // TODO: make sure destroying the tail link doesn't result in any null references //tail.Clear() below fixes this? Destroy(trans.gameObject); } // and the head spawns a food foodSpawner.MakeFood(transform.position); RemoveScore(); KillSnake(); }
void GenerateRandomObject(int level = Constant.LEVEL_1) { FoodController.FoodType foodType = DelegateManager.GetRandomFoodType(); FoodController fController = DelegateManager.GetFood(foodType); fController.IsUsed = true; PetIconController.PetType petType = DelegateManager.GetRandomPetType(level); PetIconController piController = DelegateManager.GetPetIcon(level, petType); piController.IsUsed = true; BaseObject controller = GetObjectInPool(); controller.ActivateBaseObject(true); controller.LinkFoodAndPetIcon(ref fController, ref piController); controller.ActivateFoodAndPetIcon(true); //controller.FDController = fController; //controller.PIController = piController; controller.UpdateObjectState(BaseObject.ObjectState.CanMoved); m_ListObjects.Add(controller); //Update position in here now + update last object reference Vector3 newPos = new Vector3(m_LastObject.GetTransformation().position.x + m_Offset, m_PosY, 0); controller.UpdatePositionInWorld(newPos); m_LastObject = controller; }
public void TestIfGetAllUserFoodsReturnsCorrectData() { string exampleUserId = "1"; var options = new DbContextOptionsBuilder <FitnessTrackerDBContext>() .UseInMemoryDatabase(databaseName: "FoodListDatabase") .Options; // Insert seed data into the database using one instance of the context using (var context = new FitnessTrackerDBContext(options)) { context.Foods.Add(new Food() { Id = 1, Name = "Apple", UserId = exampleUserId }); context.Foods.Add(new Food() { Id = 2, Name = "Pear", UserId = exampleUserId }); context.SaveChanges(); } // Use a clean instance of the context to run the test using (var context = new FitnessTrackerDBContext(options)) { foodContr = new FoodController(context); Assert.That(foodContr.GetAllUserFoods(exampleUserId).Count == 2, "No foods gets added into the database!"); } }
public void CanUpdatePantry() { // setup MyContext mc = new MyContext(); MockIFoodRepository foodRepository = new MockIFoodRepository(mc); MockIPantryRepository pantryRepository = new MockIPantryRepository(mc); FoodController controller = new FoodController(foodRepository, pantryRepository); Pantry p = new Pantry { PantryID = 0, Units = 35 }; // execute food update // have to create a new controller context and make the httpcontext equal fakehttpcontext so the controller can // use the session when testing controller.ControllerContext = new System.Web.Mvc.ControllerContext() { HttpContext = FakeHttpContext() }; controller.update(0); controller.update(p); // assert food has been updated p = pantryRepository.Pantrys.Select(x => x).Where(x => x.PantryID == 0).First(); Assert.AreEqual(35, p.Units); }
public List <BFood> GetAllFoodStarters() { FoodController foodController = new FoodController(); List <BFood> foundFoods = foodController.GetAllFoodStarters(); return(foundFoods); }
public FoodEntity GET_OBJECT_FOOD_BY_FOODID(string foodID) { FoodController objController = new FoodController(); FoodEntity entity = objController.Get_Object_Food_By_FoodID(foodID); return(entity); }
public void UpdateFood(int id, string name, decimal price, BFoodCategory foodCategory) { BFood food = new BFood(id, name, price, foodCategory); FoodController foodController = new FoodController(); foodController.UpdateFood(food); }
public void DeleteFood(int id) { BFood food = new BFood(id); FoodController foodController = new FoodController(); foodController.DeleteFood(food); }
public void CreateFood(string name, decimal price, int foodCategoryId, BFoodCategory foodCategory) { BFood food = new BFood(name, price, foodCategoryId, foodCategory); FoodController foodController = new FoodController(); foodController.CreateFood(food); }
private void RegClicked(object sender, EventArgs e) { var food = new { Id = tbId.Text, Name = tbName.Text, Quantity = Convert.ToInt32(tbQuantity.Text), Price = Convert.ToInt32(tbPrice.Text), RestId = tbRestId.Text }; var RestResult = RestaurantController.GetRestaurant(tbRestId.Text); if (RestResult != null) { var result = FoodController.AddFood(food); if (result) { MessageBox.Show("Food Added", "Food Registration", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("Could not Add Food", "Invalid Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Could not Add Restaurant", "Invalid Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <BFood> GetAllFoodMainCourses() { FoodController foodController = new FoodController(); List <BFood> foundFoods = foodController.GetAllFoodMainCourses(); return(foundFoods); }
public List <FoodEntity> GET_LIST_FOOD_BY_STOREID(string storeID) { FoodController objController = new FoodController(); List <FoodEntity> list = objController.Get_List_Food_By_StoreID(storeID); return(list); }
private void Start() { QuitOnConnectionError(); foodController = GetComponent <FoodController>(); arcoreDevice = GameObject.FindGameObjectWithTag("Player"); tempCamera.SetActive(false); }
public List <FoodEntity> GET_LIST_FOOD_BY_CATEGORYID(string categoryID) { FoodController objController = new FoodController(); List <FoodEntity> list = objController.Get_List_Food_By_Category(categoryID); return(list); }
public void ShouldReturnFoodById() { var dateTimeProvider = new Mock <IDateTimeProvider>(); dateTimeProvider.Setup(x => x.GetDateTime()).Returns(new DateTime(2021, 06, 01)); var options = new DbContextOptionsBuilder <FoodContext>().UseInMemoryDatabase(databaseName: "MovieListDatabase").Options; _ctx.Foods.Add(new Food() { Carbohydrate = 1, Category = new foodTrackerApi.Category(), Fat = 9, Id = 1, ModifiedDate = dateTimeProvider.Object.GetDateTime(), Name = "test", Protein = 111 }); _ctx.SaveChanges(); var mockLogger = new Mock <ILogger <FoodController> >(); var controller = new FoodController(mockLogger.Object, _ctx); var res = controller.GetFoodById(1); Assert.Equal(new DateTime(2021, 06, 01), dateTimeProvider.Object.GetDateTime()); Assert.IsAssignableFrom <OkObjectResult>(res.Result); }
/// <summary> /// Function that will look for a local player food controller object and get a reference to it. /// /// Since the ability controller starts before the main scene is initialised, we can only get references /// to main scene objects after the main scene has loaded. These methods are called to attach the /// ability controller to the respective main scene objects. /// </summary> /// <returns>This ability controller, so that calls can be chained.</returns> public AbilityController AttachToFoodController() { foodController = GameObject.Find("FoodController").GetComponent<FoodController>(); if (foodController == null) { Debug.LogError(player.Name + " AbilityController failed to attach to FoodController."); return this; } Debug.Log(player.Name + " AbilityController component attached to food controller."); return this; }
// Use this for initialization void Start() { audio = GetComponent<AudioSource>(); audio.PlayOneShot(SoundInGameBGM); // Get food controller and mouse references foodController = GameObject.Find("FoodController").GetComponent<FoodController>(); mouse = GameObject.Find("Mouse").GetComponent<Mouse>(); foodPool = GetComponent<ObjectPool>(); foodPool.PoolObject = Resources.Load("Prefabs/Normal") as GameObject; abilityController = GameObject.FindGameObjectsWithTag("Player") .First(o => o.GetComponent<AbilityController>().isLocalPlayer) .GetComponent<AbilityController>(); abilityController.AttachToFoodController() .AttachToMouse() .AttachToLevelController() .AttachToAbilityUi() .AttachToMessageBox(); // Get Combo UI comboUI = GameObject.Find("Combo"); comboText = GameObject.Find("ComboText"); comboTextAnimator = comboText.GetComponent<Animator>(); comboChange = GameObject.Find("ComboChange"); comboChangeAnimator = comboChange.GetComponent<Animator>(); comboMouse = GameObject.Find("ComboMouse"); comboText.SetActive(false); comboMouse.SetActive(false); for (int i = 0; i < comboImages.Length; i++) { Transform comboChild = comboUI.transform.GetChild(i); comboImages[i] = comboChild.GetChild(0).GetComponent<Image>(); comboBackgrounds[i] = comboChild.GetComponent<Image>(); comboAnimators[i] = comboChild.GetComponent<Animator>(); comboAnimators[i].enabled = false; // disable or it will override sprite renderer } // Get players UI playerAvatarUI = GameObject.Find("PlayerUI"); // Get Frenzy UI frenzyText = GameObject.Find("FeedingFrenzy"); frenzyBackground = GameObject.Find("FrenzyBackground"); frenzyFed = GameObject.Find("FrenzyFed"); frenzyMouseAnimator = GameObject.Find("FrenzyMouse").GetComponent<Animator>(); frenzyText.SetActive(false); frenzyBackground.SetActive(false); frenzyFed.SetActive(false); // Get Scary Cat UI scaryCatShock = GameObject.Find("Shock"); scaryCat = GameObject.Find("Cat"); scaryCatShock.SetActive(false); scaryCat.SetActive(false); // Get EndGame UI endGame = GameObject.Find("EndGame"); endGame.SetActive(false); // Initialization for food combo // All treats are eligible eligibleFoods = foodController.FoodValues.Where(kvp => kvp.Value > 0).Select(x => x.Key).ToArray<string>(); /*eligibleFoods = foodController.MaxFoodCounts.Where(kvp => kvp.Value * foodController.FoodSpawnWeights[kvp.Key] / foodController.TotalFoodSpawnWeight >= WeightedFoodCountMin && foodController.FoodValues[kvp.Key] > 0). Select(x => x.Key).ToArray<string>();*/ foreach (string food in eligibleFoods) Debug.Log("Eligible foods are " + food); // Start updating food combo StartCoroutine(primer()); StartCoroutine(updateFoodCombo()); }