예제 #1
0
        public void GarageFacroty_StoreNewAppointment_Is_Valid_Checking_Minutes()
        {
            var bookingModel = new BookingModel();

            bookingModel.Name      = "Mario";
            bookingModel.StartTime = DateTime.Today.Add(new TimeSpan(3, 13, 0, 0));
            bookingModel.EndTime   = DateTime.Today.Add(new TimeSpan(3, 15, 20, 0));

            var listBookeAppoinments = new List <BookingModel>();
            var appointmentBooked    = new BookingModel();

            appointmentBooked.Name      = "Mario";
            appointmentBooked.StartTime = DateTime.Today.Add(new TimeSpan(3, 15, 20, 0));
            appointmentBooked.EndTime   = DateTime.Today.Add(new TimeSpan(3, 17, 0, 0));
            listBookeAppoinments.Add(appointmentBooked);

            _mockHelper.Setup(fake => fake.WriteToFile(It.IsAny <string>(), It.IsAny <string>()));

            _mockCommon.Setup(fake => fake.GetModelFromString(It.IsAny <string>())).Returns(bookingModel);
            _mockCommon.Setup(fake => fake.ListAppointmentBookedPerDay(It.IsAny <string>(), It.IsAny <int>())).Returns(listBookeAppoinments);
            var garage = new PlainTextSource(_mockCommon.Object, _mockHelper.Object);
            var result = garage.StoreNewAppointment("test");

            Assert.AreEqual(true, result.Contains("The appointment has be booked"));
        }
예제 #2
0
        public void GarageFacroty_StoreNewAppointment_Return_error_Message_When_The_Model_Is_Null()
        {
            _mockCommon.Setup(fake => fake.GetModelFromString(It.IsAny <string>())).Returns <BookingModel>(null);
            var garage = new PlainTextSource(_mockCommon.Object, null);
            var result = garage.StoreNewAppointment("test");

            Assert.AreEqual(true, result.StartsWith("The data insered are incorrect"));
        }
예제 #3
0
        public void GarageFacroty_StoreNewAppointment_Return_error_Date_When_The_Model_Has_Date_In_The_Past()
        {
            var bookingModel = new BookingModel();

            bookingModel.StartTime = DateTime.Parse("01-06-2018 12:00");
            _mockCommon.Setup(fake => fake.GetModelFromString(It.IsAny <string>())).Returns(bookingModel);
            var garage = new PlainTextSource(_mockCommon.Object, null);
            var result = garage.StoreNewAppointment("test");

            Assert.AreEqual(true, result.Contains("The appointment cannot be booked with time in the past"));
        }
예제 #4
0
        public void GarageFacroty_ShowAvailableAppointments_Return_error_Message_When_Throws_Exception_Cheking_File()
        {
            _mockCommon.Setup(fake => fake.ListAppointmentBookedPerDay(It.IsAny <string>(), It.IsAny <int>())).Throws(new Exception());
            var           garage     = new PlainTextSource(_mockCommon.Object, null);
            PrivateObject maxDaysObj = new PrivateObject(garage);

            maxDaysObj.SetField("maxNextDays", 1);
            var result = garage.ShowAvailableAppointments();
            var errorMessageAspected = "There is a fatal error in the file";

            Assert.AreEqual(true, result.StartsWith(errorMessageAspected));
        }
예제 #5
0
        public void GarageFacroty_ShowAvailableAppointments_Return_Valid_Message_When_No_Appoinments_Booked_Today()
        {
            var listBookedAppointments = new Dictionary <DateTime, List <BookingModel> >();
            var textListAppointment    = "All mechanics are avaialble in this day";

            _mockCommon.Setup(fake => fake.ListAppointmentBookedPerDay(It.IsAny <string>(), It.IsAny <int>())).Returns(new List <BookingModel>());
            _mockCommon.Setup(fake => fake.ShowFreeTimeNextTenDays(It.IsAny <Dictionary <DateTime, List <BookingModel> > >(), It.IsAny <string>(), It.IsAny <string>())).Returns(textListAppointment);
            var garage = new PlainTextSource(_mockCommon.Object, null);
            var result = garage.ShowAvailableAppointments();
            var appoinentAvailableAspected = "All mechanics are avaialble in this day";

            Assert.AreEqual(true, result.Contains(appoinentAvailableAspected));
        }
예제 #6
0
        public void GarageFacroty_StoreNewAppointment_Return_error_Cannot_Be_Booked_When_The_Mechanic_Has_Already_Booked_Same_Time_Cheking_minutes()
        {
            var bookingModel = new BookingModel();

            bookingModel.Name      = "Mario";
            bookingModel.StartTime = DateTime.Today.Add(new TimeSpan(3, 13, 0, 0));
            bookingModel.EndTime   = DateTime.Today.Add(new TimeSpan(3, 15, 20, 0));

            var listBookeAppoinments = new List <BookingModel>();
            var appointmentBooked    = new BookingModel();

            appointmentBooked.Name      = "Mario";
            appointmentBooked.StartTime = DateTime.Today.Add(new TimeSpan(3, 15, 15, 0));
            appointmentBooked.EndTime   = DateTime.Today.Add(new TimeSpan(3, 16, 0, 0));
            listBookeAppoinments.Add(appointmentBooked);

            _mockCommon.Setup(fake => fake.GetModelFromString(It.IsAny <string>())).Returns(bookingModel);
            _mockCommon.Setup(fake => fake.ListAppointmentBookedPerDay(It.IsAny <string>(), It.IsAny <int>())).Returns(listBookeAppoinments);
            var garage = new PlainTextSource(_mockCommon.Object, null);
            var result = garage.StoreNewAppointment("test");

            Assert.AreEqual(true, result.Contains("The appointment cannot be booked as"));
        }