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 TestAddCategoryToCategory()
        {
            // Arrange
            EventCtrl     eCtrl = new EventCtrl();
            ComponentCtrl cCtrl = new ComponentCtrl();
            UserCtrl      uCtrl = new UserCtrl();
            var           u     = uCtrl.CreateUser("Test User", "Test User", "test" + Guid.NewGuid() + "@email.com", "password");
            var           e     = eCtrl.CreateEvent("Testing Event", "Test", 2, 20, 100, "Right here", DateTime.Now.AddHours(5), true, u);
            var           c1    = cCtrl.CreateCategory("Testing Category Lvl 1", "Test", null);

            // Act
            eCtrl.AddCategory(e, c1);

            var c2 = cCtrl.CreateCategory("Testing Category Lvl 2", "Test", c1);
            var e2 = eCtrl.FindById(e.Id);

            eCtrl.AddCategory(e2, c2);

            Assert.IsTrue(c2.Parent.Id == c1.Id);
            Assert.IsTrue(c2.EventId == e.Id);
        }
Esempio n. 3
0
        public void TestCreateCategory()
        {
            // Arrange
            ComponentCtrl cCtrl       = new ComponentCtrl();
            string        title       = "Category name";
            string        description = "Category description";

            // Act
            var cat = cCtrl.CreateCategory(title, description, null);

            // Assert
            var foundCategory = cCtrl.FindCategoryById(cat.Id);

            Assert.IsTrue(foundCategory.Title == title);
            Assert.IsTrue(foundCategory.Description == description);
        }
Esempio n. 4
0
        public void AddCategoryToEvent(int eventId, string categoryTitle, string categoryDescription, Component parent)
        {
            if (categoryTitle == "")
            {
                throw new ArgumentException("Der skal indtastes en titel");
            }
            if (categoryDescription == "")
            {
                throw new ArgumentException("Der skal indtastes en beskrivelse");
            }

            // TODO could refactor to ectrl
            Category c = cCtrl.CreateCategory(categoryTitle, categoryDescription, parent);
            Event    e = eCtrl.FindById(eventId);

            eCtrl.AddCategory(e, c);
        }