private static void _insertTreatment()
        {
            TreatmentController treatmentCtrl = new TreatmentController();
            Treatment_DTO       treatment     = new Treatment_DTO(1, "Stor fed klip, lang hår", "Vi klipper langt hår på damer", 30, 499.95m, new List <int> {
                1
            });


            treatmentCtrl.Post(treatment);
        }
예제 #2
0
        public void TestCreateTreatment1_Valid()
        {
            //Arrange

            //Act
            _watch.Start();
            IHttpActionResult addedTreatmentResult = _treatmentCtrl.Post(_treatment);

            _watch.Stop();

            //Assert
            Assert.IsInstanceOfType(addedTreatmentResult, typeof(OkNegotiatedContentResult <Treatment>));
            Treatment addedTreatmentObj = ((OkNegotiatedContentResult <Treatment>)addedTreatmentResult).Content;

            Assert.AreEqual(_treatment.Name, addedTreatmentObj.Name);
            Assert.AreEqual(_treatment.Description, addedTreatmentObj.Description);
            Assert.AreEqual(_treatment.Duration, addedTreatmentObj.Duration);
            Assert.AreEqual(_treatment.Price, addedTreatmentObj.Price);
            Assert.IsTrue(_watch.ElapsedMilliseconds < 2500);
        }
        public void PostTreatment()
        {
            // Arrange
            TreatmentController controller = new TreatmentController();

            Treatment TreatmentObj = new Treatment
            {
                TreatmentName = "Third",
            };
            var actResult = controller.Post(TreatmentObj);
            // Act
            var result = actResult as OkNegotiatedContentResult <Treatment>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.ID > 0);
        }
        public void SetUp()
        {
            _reservationCtrl = new ReservationController();
            _treatmentCtrl   = new TreatmentController();
            _employeeCtrl    = new EmployeeController();
            _watch           = new Stopwatch();
            DbCleanUp.CleanDB();
            InsertTestData.InsertData();

            _categories = new List <int>()
            {
                1
            };

            Treatment_DTO treatment = new Treatment_DTO(1, "Voks af ryg", "Vi benytter enten almindelig varm voks eller sugaring", 60, 699.95m, _categories);

            _treatmentCtrl.Post(treatment);
        }
        public void TestCreateReservation3_TimeOverlap()
        {
            //Arrange
            Treatment_DTO treatment2 = new Treatment_DTO(1, "Voks af bryst", "Vi benytter enten almindelig varm voks eller sugaring", 60, 399.95m, _categories);

            _treatmentCtrl.Post(treatment2);

            Reservation_DTO newReservation    = new Reservation_DTO(2, 1, 1, DateTime.Parse("26-02-2025 13:30"));
            Reservation_DTO doubleReservation = new Reservation_DTO(1, 1, 1, DateTime.Parse("26-02-2025 14:00"));

            //Act
            _watch.Start();
            IHttpActionResult addedReservationResult       = _reservationCtrl.Post(newReservation);
            IHttpActionResult addedReservationDoubleResult = _reservationCtrl.Post(doubleReservation);

            _watch.Stop();

            //Assert
            Assert.IsInstanceOfType(addedReservationDoubleResult, typeof(NegotiatedContentResult <string>));
            Assert.IsTrue(((NegotiatedContentResult <string>)addedReservationDoubleResult).StatusCode == System.Net.HttpStatusCode.Conflict);
            Assert.IsTrue(_watch.ElapsedMilliseconds < 2500);
        }