public void SetValueFecha_FechaCorrecta_FechaAsignadaCorrectamente()
        {
            //Arrange
            ValidateDate SUT = new ValidateDate();

            SUT.ConvertirFecha = (fecha) => new DateTime(2019, 1, 28);

            //Act
            var resultado = SUT.SetValueFecha("Fecha");

            //Assert
            Assert.AreEqual(new DateTime(2019, 1, 28), resultado);
        }
        public void SetMinutesTest(string cFecha, int iResult)
        {
            //Arrange
            ValidateDate SUT = new ValidateDate();

            SUT.FechaActual = () => new DateTime(2020, 1, 28, 19, 0, 0);
            DateTime dtFechaEvaluar = Convert.ToDateTime(cFecha);

            //Act
            var resultado = SUT.SetMinutes(dtFechaEvaluar);

            //Assert
            Assert.AreEqual(iResult, resultado);
        }
        public void DeterminePastEvent_FechaRecibida_DeterminaCorrectamenteFecha(string cFecha, bool lResult)
        {
            //Arrange
            ValidateDate SUT = new ValidateDate();

            SUT.ConvertirFecha = (fecha) => new DateTime(2019, 1, 28);
            DateTime dtFechaEvaluar = Convert.ToDateTime(cFecha);

            //Act
            var resultado = SUT.DeterminePastEvent(dtFechaEvaluar);

            //Assert
            Assert.AreEqual(lResult, resultado);
        }
示例#4
0
        static void Main(string[] args)
        {
            IDetermineType        determineType        = new DetermineType();
            IValidateDate         validateDate         = new ValidateDate();
            IDetermineTypeFactory determineTypeFactory = new DetermineTypeFactory();
            IEventService         eventService         = new EventsService(determineType, validateDate, determineTypeFactory);
            IFileService          fileService          = new FileService(validateDate);
            IObtainFileService    obtainFileService    = new ObtainFileService();
            IValidateFile         validateFile         = new ValidateFile();
            IDisplayInfoService   displayInfoService   = new DisplayInfoService();

            EventManagement eventManagement = new EventManagement(eventService, fileService, obtainFileService, validateFile, displayInfoService);

            eventManagement.Init();
        }
示例#5
0
        private void Add()
        {
            Console.Clear();

            Event events = new Event();

            Console.WriteLine("Add new Event:");

            Console.Write("Name: ");
            events.Name = Console.ReadLine();

            Console.Write("Location: ");
            events.Location = Console.ReadLine();

            while (!ValidDate)
            {
                Console.Write("Please enter Start Date in format DD.MM.YYYY: ");
                events.StartDateInput = Console.ReadLine();
                ValidDate             = ValidateDate.ValidateData(events.StartDateInput);

                Console.Write("Please enter End Date in format DD.MM.YYYY: ");
                events.EndDateInput = Console.ReadLine();
                ValidDate           = ValidateDate.ValidateData(events.EndDateInput);
            }
            while (!ValidTime)
            {
                Console.Write("Please enter Start Time in format HH:mm:ss: ");
                events.StartTimeInput = Console.ReadLine();
                ValidTime             = ValidateTime.ValidatingTime(events.StartTimeInput);

                Console.Write("Please enter End Time in format HH:mm:ss: ");
                events.EndTimeInput = Console.ReadLine();
                ValidTime           = ValidateTime.ValidatingTime(events.EndTimeInput);
            }

            Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt");
            eventsRepository.Save(events);

            Console.WriteLine("Event saved successfully.");
            Console.ReadKey(true);
        }
示例#6
0
        private void Update()
        {
            Console.Clear();

            Console.Write("Event ID: ");
            int eventId = Convert.ToInt32(Console.ReadLine());

            Repository.EventRepository eventsRepository = new Repository.EventRepository("events.txt");
            Event events = eventsRepository.GetById(eventId);

            if (events == null)
            {
                Console.Clear();
                Console.WriteLine("Event not found.");
                Console.ReadKey(true);
                return;
            }

            Console.WriteLine("Editing Event (" + events.Name + ")");
            Console.WriteLine("ID:" + events.Id);

            Console.WriteLine("Name :" + events.Name);
            Console.Write("New Name:");
            string name = Console.ReadLine();

            Console.WriteLine("Location :" + events.Location);
            Console.Write("New Location:");
            string location = Console.ReadLine();

            Console.WriteLine("Start Date :" + events.StartDateInput);
            Console.Write("New Start Date in format DD.MM.YYYY: ");
            string startDate = Console.ReadLine();

            ValidDate = ValidateDate.ValidateData(startDate);

            Console.WriteLine("End Date :" + events.EndDateInput);
            Console.Write("New End Date in format DD.MM.YYYY: ");
            string endDate = Console.ReadLine();

            ValidDate = ValidateDate.ValidateData(endDate);

            Console.WriteLine("Start Time :" + events.StartTimeInput);
            Console.Write("New Start Time in format HH:mm:ss: ");
            string startTime = Console.ReadLine();

            ValidTime = ValidateTime.ValidatingTime(startTime);

            Console.WriteLine("End Time :" + events.EndTimeInput);
            Console.Write("New End Time in format HH:mm:ss: ");
            string endTime = Console.ReadLine();

            ValidTime = ValidateTime.ValidatingTime(endTime);

            if (!string.IsNullOrEmpty(name))
            {
                events.Name = name;
            }
            if (!string.IsNullOrEmpty(location))
            {
                events.Location = location;
            }
            if (!string.IsNullOrEmpty(startDate))
            {
                events.StartDateInput = startDate;
            }
            if (!string.IsNullOrEmpty(endDate))
            {
                events.EndDateInput = endDate;
            }
            if (!string.IsNullOrEmpty(startTime))
            {
                events.StartTimeInput = startTime;
            }
            if (!string.IsNullOrEmpty(endTime))
            {
                events.EndTimeInput = endTime;
            }

            eventsRepository.Save(events);

            Console.WriteLine("Event saved successfully.");
            Console.ReadKey(true);
        }