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); }
/// <summary> /// Checks for empty textfields and if none, then it calls "CreateEscapeRoom", "EmptyText" and "UpdateEscapeRoomList" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreateEscapeRoom_Click(object sender, EventArgs e) { EscapeRoomCtr esC = new EscapeRoomCtr(); if (txtName.Text.Trim().Equals("")) { lblErrorName.Visible = true; lblErrorName.Text = "Mangler input"; } else if (txbDescription.Text.Trim().Equals("")) { lblErrorDesciption.Visible = true; lblErrorDesciption.Text = "Mangler input"; } else if (txtMaxClearTime.Text.Trim().Equals("")) { lblErrorMaxClearTime.Visible = true; lblErrorMaxClearTime.Text = "Mangler input"; } else if (txtCleanTime.Text.Trim().Equals("")) { lblErrorCleanTime.Visible = true; lblErrorCleanTime.Text = "Mangler input"; } else if (txtPrice.Text.Trim().Equals("")) { lblErrorPrice.Visible = true; lblErrorPrice.Text = "Mangler input"; } else if (txtEmployeeID.Text.Trim().Equals("")) { lblErrorEmployee.Visible = true; lblErrorEmployee.Text = "Mangler input"; } else if (pbEscaperoom.Image == null) { lblErrorImage.Visible = true; } else { decimal MaxC = decimal.Parse(txtMaxClearTime.Text); decimal ClTi = decimal.Parse(txtCleanTime.Text); decimal Pri = decimal.Parse(txtPrice.Text); decimal rating = 0; int Emp = int.Parse(txtEmployeeID.Text); byte[] img = ConvertImgToBinary(pbEscaperoom.Image); esC.CreateEscapeRoom(txtName.Text, txbDescription.Text, MaxC, ClTi, Pri, rating, Emp, img); EmptyText(); UpdateEscapeRoomList(); } }