Пример #1
0
        public async Task ProcessTeamsMeeting()
        {
            var _graphHelper     = new MockGraphHelper();
            var _logger          = new InMemoryLogger <MsGraphAdapter>();
            var _courseCatalog   = new MockSharepointCourseCatalog();
            var _eventAggregator = new MockEventAggregator();
            var _graphAdapter    = new MsGraphAdapter(_eventAggregator, _logger, _graphHelper, _courseCatalog);


            string courseId          = "COMP0102";
            string listToStoreEvents = "Attendance Events";

            _courseCatalog.mockCatalog.Add(courseId, new CourseCatalogType {
                ListName = listToStoreEvents, JoinWebUrl = "testjoinweburl.com"
            });

            // JoinWebUrl does not exist in course catalog
            var callIdJoinWebUrlNotExist = "22222";
            await _graphAdapter.ProcessEvents(callIdJoinWebUrlNotExist);

            Assert.Empty(_eventAggregator.processedEvents);

            //Only organiser is in meeting
            var callIdJoinWebUrlOrganiserOnly = "44444";
            await _graphAdapter.ProcessEvents(callIdJoinWebUrlOrganiserOnly);

            Assert.Empty(_eventAggregator.processedEvents);

            // JoinWebUrl exists in course catalog
            var callIdJoinWebUrl = "33333";
            await _graphAdapter.ProcessEvents(callIdJoinWebUrl);

            Assert.Single(_eventAggregator.processedEvents);

            //Ensure event organiser data isn't sent to event aggregator
            Assert.True(1 == _eventAggregator.processedEvents.Count());

            //Correct student data is stored
            var processedEvent = _eventAggregator.processedEvents[0];

            Assert.Equal("COMP0102", processedEvent.CourseID);
            Assert.Equal(EventType.Attendance, processedEvent.EventType);
            Assert.Equal("Meeting", processedEvent.ActivityType);
            Assert.Equal("Weekly Lecture", processedEvent.ActivityName);
            Assert.Equal("*****@*****.**", processedEvent.Student.Email);
            Assert.Equal("John", processedEvent.Student.FirstName);
            Assert.Equal("Doe", processedEvent.Student.LastName);
            Assert.Equal("00000", processedEvent.Student.ID);
        }
Пример #2
0
        public async Task <ActionResult <string> > Post([FromQuery] string validationToken = null)
        {
            // handle validation
            if (!string.IsNullOrEmpty(validationToken))
            {
                _logger.LogDebug($"Received Token: '{validationToken}'");
                return(Ok(validationToken));
            }

            // handle notifications
            using (StreamReader reader = new StreamReader(Request.Body))
            {
                string content = await reader.ReadToEndAsync();

                _logger.LogDebug("Received notification: " + content);

                var notifications = JsonConvert.DeserializeObject <Notifications>(content);

                foreach (var notification in notifications.Items)
                {
                    _logger.LogDebug($"Received notification: '{notification.Resource}', {notification.ResourceData?.Id}");
                    await _graphAdapter.ProcessEvents(notification.ResourceData?.Id);
                }
            }

            return(Ok());
        }
Пример #3
0
        public async Task ProcessTeamsMeetingWithoutJoinWebUrl()
        {
            var _graphHelper     = new MockGraphHelper();
            var _logger          = new InMemoryLogger <MsGraphAdapter>();
            var _courseCatalog   = new MockSharepointCourseCatalog();
            var _eventAggregator = new MockEventAggregator();
            var _graphAdapter    = new MsGraphAdapter(_eventAggregator, _logger, _graphHelper, _courseCatalog);

            var    callId            = "11111";
            string courseId          = "COMP0102";
            string listToStoreEvents = "Attendance Events";

            _courseCatalog.mockCatalog.Add(courseId, new CourseCatalogType {
                ListName = listToStoreEvents, JoinWebUrl = "testjoinweburl.com"
            });

            await _graphAdapter.ProcessEvents(callId);

            Assert.Empty(_eventAggregator.processedEvents);
        }