示例#1
0
        public void TestDeleteEventsByTitle()
        {
            EventsManager eventManager = new EventsManager();
            EventsProcessor eventProcessor = new EventsProcessor(eventManager);

            DateTime date = DateTime.ParseExact("2011-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            Event calendarEvent = new Event
            {
                EventDate = date,
                Title = "C# exam",
                Location = null
            };

            EventsManager eventsManager = new EventsManager();

            eventsManager.AddEvent(calendarEvent);

            eventsManager.DeleteEventsByTitle("C# exam");

            IEnumerable<Event> eventsList = eventManager.ListEvents(date, 3);

            int expected = 0;
            int actual = 0;

            foreach (Event currentEvent in eventsList)
            {
                actual++;
            }

            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Started daemon.");

            var exchangeInfo = new ExchangeInfo("exchange name", ExchangeType.Direct);
            IReadOnlyCollection <RouteKey> routing = new List <RouteKey>
            {
                new RouteKey("all admin user moderator", new List <QueueInfo>
                {
                    new QueueInfo("queue1"),
                    new QueueInfo("queue2")
                }),
                new RouteKey("dante nooby", new List <QueueInfo>
                {
                    new QueueInfo("queue3"),
                    new QueueInfo("queue4")
                })
            };
            var eventConfig = new EventConfig(exchangeInfo, routing);

            EventsManager.AddEvent <UpdateUser>(eventConfig, new ConnectionFactory());
            var updateUser = new UpdateUser(Guid.NewGuid(), "new user name");
            await EventsManager.SendEvent(updateUser, "all admin user moderator");

            await Task.CompletedTask;
        }
示例#3
0
        public void TestAddEvent()
        {
            EventsManager eventManager = new EventsManager();
            EventsProcessor eventProcessor = new EventsProcessor(eventManager);

            DateTime date = DateTime.ParseExact("2012-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            Event calendarEvent = new Event
            {
                EventDate = date,
                Title = "C# exam",
                Location = null
            };

            EventsManager eventsManager = new EventsManager();

            eventsManager.AddEvent(calendarEvent);

            string expectedTitle = "C# exam";
            string expectedLocation = null;

            IEnumerable<Event> eventsList = eventsManager.ListEvents(date, 1);
            Event testEvent = new Event();

            foreach (Event ev in eventsList)
            {
                testEvent = ev;
            }

            Assert.AreEqual(date, testEvent.EventDate);
            Assert.AreEqual(expectedTitle, testEvent.Title);
            Assert.AreEqual(expectedLocation, testEvent.Location);
        }
示例#4
0
        public void AddEventValidFormatTest()
        {
            EventsManager manager  = new EventsManager();
            Event         occasion = new Event("title", "location", DateTime.Now);

            manager.AddEvent(occasion);
            Console.WriteLine();
        }
示例#5
0
        public void AddEventEmptyLocationTest()
        {
            EventsManager manager  = new EventsManager();
            Event         occasion = new Event("title", "", DateTime.Now);

            manager.AddEvent(occasion);

            var testObj = (MultiDictionary <string, Event>)GetInstanceField(typeof(EventsManager), manager, "_eventsDictionary");

            Assert.AreNotEqual(1, testObj.Count);
        }
示例#6
0
        public void AddEventInvalidFormatTitleTest()
        {
            EventsManager manager = new EventsManager();
            string        title   = "  t| \n itle  ";

            Event occasion = new Event(title.ToString(), "location", DateTime.Now);

            manager.AddEvent(occasion);

            var testObj = (MultiDictionary <string, Event>)GetInstanceField(typeof(EventsManager), manager, "_eventsDictionary");

            Assert.AreNotEqual(1, testObj.Count);
        }
示例#7
0
        public void AddEventTooLongLocationTest()
        {
            EventsManager manager  = new EventsManager();
            StringBuilder location = new StringBuilder();

            for (int i = 0; i <= 150; i++)
            {
                location.Append("location");
            }
            Event occasion = new Event("title", location.ToString(), DateTime.Now);

            manager.AddEvent(occasion);

            var testObj = (MultiDictionary <string, Event>)GetInstanceField(typeof(EventsManager), manager, "_eventsDictionary");

            Assert.AreNotEqual(1, testObj.Count);
        }
示例#8
0
        private void Add()
        {
            EventsManager em      = EventsManager.Instance;
            Event         anEvent = null;

            int hour   = this.spbtnHour.ValueAsInt;
            int minute = this.spbtnMinute.ValueAsInt;
            int day    = this.spbtnDay.ValueAsInt;
            int month  = this.cmbMonth.Active + 1;
            int year   = this.spbtnYear.ValueAsInt;

            DateTime date;

            try {
                date = new DateTime(year, month, day, hour, minute, 0);
            }
            catch (Exception) {
                throw new Exception("La fecha para el evento no es válida.");
            }

            if (this.cmbEventTypes.Active < 0)
            {
                throw new Exception("Se debe escoger el tipo del evento.");
            }

            EventType eventTypeSelected = EventTypesManager
                                          .Instance.Retrieve(this.cmbEventTypes.ActiveText);

            anEvent = em.AddEvent(date, this.entryName.Text.Trim(),
                                  eventTypeSelected,
                                  this.textviewGoals.Buffer.Text.Trim(),
                                  this.textviewObservations.Buffer.Text.Trim());

            // Update persons list in the main window
            MainWindow.mainWindowInstance.AddEventToList(anEvent);
        }
示例#9
0
        public ActionResult Create(Models.Event e)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string new_image = Url.Content("/images/default-event-img.png");
                    var    image     = Request.Form.Files["Images"];
                    if (image != null && image.ContentType.Contains("image/"))
                    {
                        string             fileName    = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(image.FileName);
                        GoogleDriveManager driveClient = new GoogleDriveManager(hosting);
                        new_image = driveClient.DriveUploadAndGetSrc(image, DRIVE_FOLDER_IMAGES);
                    }
                    e.Images = new_image;

                    string file_name = Request.Form["file_name"];
                    string link      = Request.Form["link"];
                    var    file      = Request.Form.Files["download"];
                    if (file != null && file.Length > 0)
                    {
                        GoogleDriveManager driveClient = new GoogleDriveManager(hosting);
                        link = driveClient.DriveUploadAndGetSrc(file, DRIVE_FOLDER_FILES);
                    }
                    e.Files = file_name + "|" + link;

                    eventsManager.AddEvent(e);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
            return(View());
        }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     eventsManager = EasyGetter.GetUIEventsManager();
     goToOptions   = new PauseEvent();
     eventsManager.AddEvent(EventType.PauseGameEvent, goToOptions);
 }
示例#11
0
 // Start is called before the first frame update
 void Start()
 {
     eventsManager = EasyGetter.GetUIEventsManager();
     goToSkills    = new SceneChangeEvent();
     eventsManager.AddEvent(EventType.ChangeSceneEvent, goToSkills);
 }
示例#12
0
 // Start is called before the first frame update
 void Start()
 {
     quit          = new GoBackMainEvent();
     eventsManager = EasyGetter.GetUIEventsManager();
     eventsManager.AddEvent(EventType.GoBackMainEvent, quit);
 }
示例#13
0
 // Start is called before the first frame update
 void Start()
 {
     eventsManager = EasyGetter.GetUIEventsManager();
     start         = new SceneChangeEvent();
     eventsManager.AddEvent(EventType.ChangeSceneEvent, start);
 }
示例#14
0
        public void TestListEventsAll()
        {
            EventsManager eventManager = new EventsManager();
            EventsProcessor eventProcessor = new EventsProcessor(eventManager);

            DateTime firstEventDate = DateTime.ParseExact("2009-03-26T12:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            Event firstEvent = new Event
            {
                EventDate = firstEventDate,
                Title = "C# exam",
                Location = null
            };

            DateTime secondEventDate = DateTime.ParseExact("2010-03-26T10:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            Event secondEvent = new Event
            {
                EventDate = secondEventDate,
                Title = "C# exam",
                Location = "Gabrovo"
            };

            DateTime thirdEventDate = DateTime.ParseExact("2013-03-26T07:43:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            Event thirdEvent = new Event
            {
                EventDate = thirdEventDate,
                Title = "C# exam",
                Location = null
            };

            DateTime listingDateTime = DateTime.ParseExact("2001-03-26T07:43:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            EventsManager eventsManager = new EventsManager();

            eventsManager.AddEvent(firstEvent);
            eventsManager.AddEvent(secondEvent);
            eventsManager.AddEvent(thirdEvent);

            IEnumerable<Event> eventsList = eventsManager.ListEvents(listingDateTime, 3);

            int expectedEventsCount = 3;
            int actualEventsCount = 0;

            foreach (Event calendarEv in eventsList)
            {
                actualEventsCount++;
            }

            Assert.AreEqual(expectedEventsCount, actualEventsCount);
        }
示例#15
0
 // Start is called before the first frame update
 void Start()
 {
     eventsManager = EasyGetter.GetUIEventsManager();
     exit          = new ExitGameEvent();
     eventsManager.AddEvent(EventType.ExitGameEvent, exit);
 }