Exemplo n.º 1
0
        public void AddItemSuccessViewRenders()
        {
            var _db        = new StoreDbContext();
            var controller = new ItemsController(_db);
            var result     = controller.AddItem();

            Assert.IsAssignableFrom(typeof(ViewResult), result);
        }
Exemplo n.º 2
0
    void OnGUI()
    {
        defaultColor = GUI.backgroundColor;
        if (ItemsController.Instance == null)
        {
            return;
        }
        library = ItemsController.Instance;

        EditorGUILayout.BeginHorizontal();
        currentType         = (Item.ItemTypes)EditorGUILayout.EnumPopup(currentType);
        GUI.backgroundColor = Color.green;
        if (GUILayout.Button("Add"))
        {
            library.AddItem(currentType);
        }
        GUI.backgroundColor = defaultColor;
        if (GUILayout.Button("Save"))
        {
            PrefabUtility.ReplacePrefab(library.gameObject, PrefabUtility.GetPrefabParent(library.gameObject), ReplacePrefabOptions.ConnectToPrefab);
        }
        if (GUILayout.Button("Revert"))
        {
            PrefabUtility.ResetToPrefabState(library.gameObject);
        }
        EditorGUILayout.EndHorizontal();

        for (int i = library.Items.Count - 1; i >= 0; i--)
        {
            Item item = library.Items[i];
            if (currentType == item.itemType)
            {
                DrawCommonProperties(item);
                if (currentType == Item.ItemTypes.Quest)
                {
                    DrawThingProperties((ItemQuest)item);
                }
                if (currentType == Item.ItemTypes.WeaponMelee)
                {
                    DrawWeaponProperties((ItemWeaponMelee)item);
                }
                if (currentType == Item.ItemTypes.Staff)
                {
                    DrawStaffProperties((ItemWeaponStaff)item);
                }
                if (currentType == Item.ItemTypes.Potion)
                {
                    DrawPotionProperties((ItemPotion)item);
                }
                if (currentType == Item.ItemTypes.Wearable)
                {
                    DrawWearableProperties((ItemWearable)item);
                }
            }
        }
    }
Exemplo n.º 3
0
        public void AddItemSuccessPosttoMockDb()
        {
            var item = new Item {
                item_id = Guid.NewGuid(), name = "item4", price = 40.00M, quantity = 15
            };

            var mockItem = new Mock <DbSet <Item> >();

            mockItem.Setup(m => m.Find(item.item_id)).Returns(item);

            var mockContext = new Mock <StoreDbContext>();

            mockContext.Setup(i => i.Items).Returns(mockItem.Object);

            var controller = new ItemsController(mockContext.Object);
            var vm         = new ItemViewModel(item);

            controller.AddItem(vm);

            mockItem.Verify(m => m.Add(It.IsAny <Item>()), Times.Once());
        }
Exemplo n.º 4
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     _controller.AddItem();
 }