Ejemplo n.º 1
0
        public void TestUpdate()
        {
            //Arrange
            EscapeRoomCtr esrCtr = new EscapeRoomCtr();
            EmployeeCtr   empCtr = new EmployeeCtr();
            EscapeRoom    Er     = new EscapeRoom()
            {
                Description  = "You know I Know I Still got it",
                MaxClearTime = 90,
                CleanTime    = 30,
                Name         = "The best",
                Price        = 300,
                Rating       = 5,
                Emp          = empCtr.Get(2)
            };

            //Act
            esrCtr.CreateEscapeRoom(Er.Name, Er.Description, Er.MaxClearTime, Er.CleanTime, Er.Price, Er.Rating, Er.Emp.EmployeeID, Er.Image);
            EscapeRoom TestEr = esrCtr.GetForOwner(esrCtr.GetAllForOwner().Count);

            esrCtr.UpdateEscapeRoom("The best", "I am the best", 200, 20, 500, 5, Er.Emp.EmployeeID, TestEr.EscapeRoomID, TestEr.Image);
            TestEr = esrCtr.GetForOwner(esrCtr.GetAllForOwner().Count);

            //Assert
            Assert.AreEqual(Er.Name, TestEr.Name);
            Assert.AreNotEqual(Er.Description, TestEr.Description);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks all the textboxes for valid data then runs UpdateEscapeRoom, shows CreateEscapeRoom and hides itself
 /// it has error messages is the data is invalid
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnUpdateRoom_Click(object sender, EventArgs e)
 {
     if (txbName.Text.Equals(""))
     {
         txbName.Text      = "Dette felt skal have en værdig";
         txbName.BackColor = Color.Red;
     }
     else if (txbDescription.Text.Equals(""))
     {
         txbDescription.Text      = "Dette felt skal have en værdig";
         txbDescription.BackColor = Color.Red;
     }
     else if (txbMaxClearTime.Text.Equals(""))
     {
         txbMaxClearTime.Text      = "";
         txbMaxClearTime.BackColor = Color.Red;
     }
     else if (txbCleanTime.Text.Equals(""))
     {
         txbCleanTime.Text      = "";
         txbCleanTime.BackColor = Color.Red;
     }
     else if (txbPrice.Text.Equals(""))
     {
         txbPrice.Text      = "";
         txbPrice.BackColor = Color.Red;
     }
     else
     {
         string  name         = txbName.Text;
         string  description  = txbDescription.Text;
         decimal maxClearTime = Convert.ToDecimal(txbMaxClearTime.Text);
         decimal cleanTime    = Convert.ToDecimal(txbCleanTime.Text);
         decimal price        = Convert.ToDecimal(txbPrice.Text);
         //skal laves om når vi har mere rating indover
         decimal rating = 0;
         int     empID;
         if (Emp == null)
         {
             empID = ER.Emp.EmployeeID;
         }
         else
         {
             empID = Emp.EmployeeID;
         }
         byte[] img;
         if (ER.Image == null)
         {
             img = ConvertImgToBinary(pbEscapeRoom.Image);
         }
         else
         {
             img = ER.Image;
         }
         ERctr.UpdateEscapeRoom(name, description, maxClearTime, cleanTime, price, rating, empID, ER.EscapeRoomID, img);
         this.Hide();
         CreateEscapeRoom cer = new CreateEscapeRoom();
         cer.Show();
     }
 }