public void CheckInventoryControllerTest() { // Arrange InventoryController controller = new InventoryController(); controller.Request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/inventory/checkInventory"); controller.Configuration = new HttpConfiguration(); // Act var result = controller.CheckInventory(Items).Result; var items = result as OkNegotiatedContentResult <List <Item> >; //Assert Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <List <Item> >)); Assert.IsNotNull(items); CollectionAssert.AllItemsAreNotNull(items.Content); Console.WriteLine(JsonConvert.SerializeObject(items.Content, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); //check badrequest var result2 = controller.CheckInventory(new List <Item>()).Result as BadRequestResult; Assert.IsNotNull(result2); }
// void LateUpdate() // { // if (!(isCollidingFloor)) // { // playerAnim.SetFloat("Speed", 1.0f); // } // } void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Goblin") { // decrease the health as long as the Goblin is in contact with the player bIsInContactWithGoblin = true; } else if (collision.gameObject.tag == "Ground") { isCollidingFloor = true; jumpBtn.GetComponent <JumpBtnHandler>().bIsClicked = false; } if (collision.gameObject.tag == "ManaStone") { // Increase mana score and set the text for the UI then destroy the pickup if (!(invCtrlObj.CheckInventory())) { manaScore++; gm.GetComponent <GM>().manaTxt.text = manaScore.ToString(); invCtrlObj.AddToInv(collision.gameObject.GetComponent <ManaStoneController>().manaItem); GameObject.Destroy(collision.gameObject); } else { Debug.Log("Inventory is Full !!! "); } } else if (collision.gameObject.tag == "Coin") { // Increase coin score and set the text for the UI then destroy the pickup if (!(invCtrlObj.CheckInventory())) { coinScore++; gm.GetComponent <GM>().scoreTxt.text = coinScore.ToString(); invCtrlObj.AddToInv(collision.gameObject.GetComponent <CoinController>().coinItem); GameObject.Destroy(collision.gameObject); } else { Debug.Log("Inventory is Full !!! "); } } if (collision.gameObject.tag == "BasicSword") { AddWeapon(); // Destroy Object GameObject.Destroy(collision.gameObject); } }
public void Inventory_MockData() { string productID = "Item1"; int quantity = 2; Exception ex = new Exception("An exception has occurred"); //var mockFRepository = new Mock<IFundsRepository>(); InventoryController inventory = new InventoryController(); List <dynamic> inventoryList = new List <dynamic>() { new { ItemID = 1, ItemName = "Item1", Description = "ABC test item" } }; bool result = inventory.CheckInventory(productID, quantity); Assert.IsTrue(result); //another way //Mock<InventoryController> name = new Mock<InventoryController>(); //name.CallBase = true; //name.Setup(x => x.CheckInventory(productID, quantity)).Returns(true); //var results = name.Object.ChargePayment(It.IsAny<string>(), It.IsAny<int>()); //string expected = string.Format("hello {0}", results); //Assert.AreEqual(expected, results); }
public void Inventory_InventoryNotExists() { string productID = "ABCTest"; int quantity = 2; // Arrange InventoryController controller = new InventoryController(); // Act bool result = controller.CheckInventory(productID, quantity); // Assert Assert.IsFalse(result); }