コード例 #1
0
 public static void MyClassInitialize(TestContext testContext)
 {
     //Add test data (order specific)
     testDatabase = new TestDatabaseHelper();
     restaurant1 = testDatabase.AddRestaurant();
     menu1 = testDatabase.AddMenu(restaurant1);
     category1 = testDatabase.AddCategory();
     item1 = testDatabase.AddItem();
 }
コード例 #2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            testDatabase = new TestDatabaseHelper();

            //Add test data (order specific)
            restaurant1 = testDatabase.AddRestaurant();
            table1 = testDatabase.AddTable(restaurant1);
            order1 = testDatabase.AddOrder(table1);
            item1 = testDatabase.AddItem();
            category1 = testDatabase.AddCategory();
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
            menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
        }
コード例 #3
0
ファイル: ItemOM.cs プロジェクト: pmoda/TFFCode
        public Boolean edit(item item)
        {
            ItemIM im = new ItemIM(db);
            item dbVersion = im.find(item.id);
            if (dbVersion.version == item.version)
            {
                ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion);
                db.Entry(item).State = EntityState.Modified;

                item.version = item.version + 1;
                db.SaveChanges();
                return true;
            }
            return false;
        }
コード例 #4
0
ファイル: TestDatabaseHelper.cs プロジェクト: pmoda/TFFCode
        /// <summary>
        /// Creates an entry of type item in the database.
        /// </summary>
        /// <returns>The created item entry.</returns>
        public item AddItem()
        {
            //Initialise
            db = new touch_for_foodEntities();
            item testItem = new item();

            //Set Attributes
            testItem.name = "UnitTest";

            //Save
            db.items.Add(testItem);
            db.SaveChanges();
            db.Dispose();

            return testItem;
        }
コード例 #5
0
ファイル: ReviewControllerTest.cs プロジェクト: pmoda/TFFCode
        public static void MyClassInitialize(TestContext testContext)
        {
            //Add test data (order specific)
            testDatabase = new TestDatabaseHelper();
            restaurant1 = testDatabase.AddRestaurant();
            table1 = testDatabase.AddTable(restaurant1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Customer);
            order1 = testDatabase.AddOrder(table1);
            item1 = testDatabase.AddItem();
            category1 = testDatabase.AddCategory();
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
            menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
            orderItem1 = testDatabase.AddOrderItem(order1, menuItem1);

            //Session
            db = new touch_for_foodEntities();
            ReviewController target = new ReviewController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
コード例 #6
0
        public static void MyClassInitialize(TestContext testContext)
        {
            testDatabase = new TestDatabaseHelper();

            //Add test data (order specific)
            item1 = testDatabase.AddItem();
            category1 = testDatabase.AddCategory();
            restaurant1 = testDatabase.AddRestaurant();
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
            table1 = testDatabase.AddTable(restaurant1);
            order1 = testDatabase.AddOrder(table1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Admin);
            review1 = testDatabase.AddReview(restaurant1, order1, user1);
        }
コード例 #7
0
ファイル: OrderOMTest.cs プロジェクト: pmoda/TFFCode
 public void MyTestInitialize()
 {
     //Add test data (order specific)
     category1 = testDatabase.AddCategory();
     restaurant1 = testDatabase.AddRestaurant();
     menu1 = testDatabase.AddMenu(restaurant1);
     menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
     table1 = testDatabase.AddTable(restaurant1);
     order1 = testDatabase.AddOrder(table1);
     item1 = testDatabase.AddItem(category1);
     menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
     orderItem1 = testDatabase.AddOrderItem(order1, menuItem1);
 }
コード例 #8
0
ファイル: ItemController.cs プロジェクト: pmoda/TFFCode
 public ActionResult Edit(item item)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (om.edit(item))
                 return RedirectToAction("Details", "Menu_Category", new { id = HttpContext.Session["editingMenuCatId"] });
             else
             {
                 ViewBag.Error = "This record has already been updated. Please refresh and try again";
             }
         }
         catch (Exception)
         {
             ViewBag.Error = Global.ServerError;
         }
     }
     ViewBag.category_id = new SelectList(db.categories, "id", "name", item.category_id);
     return View(item);
 }
コード例 #9
0
ファイル: ItemController.cs プロジェクト: pmoda/TFFCode
        public ActionResult Create(item item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (om.Create(item))
                    {
                        return RedirectToAction("Index");
                    }
                }
                catch (Exception) { }
            }

            ViewBag.Error = Global.ServerError;
            ViewBag.category_id = new SelectList(db.categories, "id", "name", item.category_id);
            return View(item);
        }
コード例 #10
0
ファイル: ItemControllerTest.cs プロジェクト: pmoda/TFFCode
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            item1 = testDatabase.AddItem(category1);
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);

            //Session
            db = new touch_for_foodEntities();
            target = new ItemController(db);
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
コード例 #11
0
ファイル: ItemControllerTest.cs プロジェクト: pmoda/TFFCode
        public void CreateItemTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            int numberOfTotalItemsBefore = db.items.ToList<item>().Count();
            item item2 = new item();
            item2.category_id = category1.id;

            //Act
            ActionResult actual = (ActionResult)target.Create(item2);

            //Assert
            db = new touch_for_foodEntities();
            int numberOfTotalItemsAfter = db.items.ToList<item>().Count();
            Assert.IsTrue((numberOfTotalItemsBefore + 1) == numberOfTotalItemsAfter);
        }
コード例 #12
0
ファイル: ItemOM.cs プロジェクト: pmoda/TFFCode
 /// <summary>
 /// Write an item object to the database
 /// </summary>
 /// <param name="item">The item to be written</param>
 /// <returns>true if successful, false otherwise</returns>
 /// <exception cref="InvalidOperationException"></exception>
 public bool Create(item item)
 {
     db.items.Add(item);
     return (db.SaveChanges() == 1);
 }
コード例 #13
0
ファイル: TestDatabaseHelper.cs プロジェクト: pmoda/TFFCode
 /// <summary>
 /// Remove item item from database.
 /// </summary>
 /// <param name="menuEntity">Item item to be removed.</param>
 public void RemoveItem(item itemEntity)
 {
     db = new touch_for_foodEntities();
     if (db.items.Find(itemEntity.id) != null)
     {
         db.items.Remove(db.items.Find(itemEntity.id));
         db.SaveChanges();
     }
     db.Dispose();
 }
コード例 #14
0
ファイル: TestDatabaseHelper.cs プロジェクト: pmoda/TFFCode
        /// <summary>
        /// Creates an entry of type menu itemin the database.
        /// </summary>
        /// <param name="itemEntity">The item the menu item represents.</param>
        /// <param name="menuCategory">Category the menu item belongs to</param>
        /// <returns>The created menu item entry.</returns>
        public menu_item AddMenuItem(item itemEntity, menu_category menuCategory)
        {
            //Initialise
            db = new touch_for_foodEntities();
            menu_item testMenuItem = new menu_item();

            //Set Attributes
            testMenuItem.item_id = itemEntity.id;
            testMenuItem.menu_category_id = menuCategory.id;
            testMenuItem.price = new decimal(10.99);
            testMenuItem.is_active = false;

            //Save
            db.menu_item.Add(testMenuItem);
            db.SaveChanges();
            db.Dispose();

            return testMenuItem;
        }
コード例 #15
0
ファイル: ItemFilterVM.cs プロジェクト: pmoda/TFFCode
 public void addItem(item item)
 {
     items.Add(item);
 }