Esempio n. 1
0
        public void TestAddItem()
        {
            // Arrange
            ComponentCtrl cCtrl = new ComponentCtrl();
            EventCtrl     eCtrl = new EventCtrl();
            UserCtrl      uCtrl = new UserCtrl();
            var           u     = uCtrl.CreateUser("Test User", "Test User", "test" + Guid.NewGuid() + "@email.com", "password");

            // Act
            var evnt     = eCtrl.CreateEvent("E Title", "E Desc", 42, 42, 42, "E Location", DateTime.Now.AddDays(5), true, u);
            var category = cCtrl.CreateCategory("Cat Name", "Cat desc", null);

            eCtrl.AddCategory(evnt, category);
            var category2 = cCtrl.CreateCategory("Cat2 Name2", "Cat2 desc2", category);

            eCtrl.AddCategory(evnt, category2);
            var item = cCtrl.CreateItem("Item Name", "Item Desc", 42, category2, evnt);

            eCtrl.AddItem(evnt, category2, item);

            // Assert
            var foundCategory = cCtrl.FindCategoryById(category2.Id);
            var foundItem     = ((Item)((Category)evnt.Components[1]).Components[0]);

            Assert.IsNotNull(foundItem);
            Assert.IsTrue(foundCategory.Components.Count == 1);
            Assert.IsTrue(foundCategory.Components[0].Id == foundItem.Id);
        }
Esempio n. 2
0
        public void AddItemToCategory(int eventId, int categoryId, int amount, string itemTitle, string itemDescription)
        {
            Category c    = cCtrl.FindCategoryById(categoryId);
            Event    e    = eCtrl.FindById(eventId);
            Item     item = cCtrl.CreateItem(itemTitle, itemDescription, amount, c, e);

            eCtrl.AddItem(e, c, item);
        }