コード例 #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);
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: UCN3semGRP2/potlog
 public Category FindCategoryById(int id)
 {
     return(cCtrl.FindCategoryById(id));
 }