예제 #1
0
        public async Task ProcessEventIgnoresAttendanceEventIfNotFoundInCourseCatalog()
        {
            var          mockSharepointManager = new MockSharepointManager();
            var          emptyCourseCatalog    = new MockSharepointCourseCatalog();
            const string listToStoreEvents     = "Attendance Events";

            mockSharepointManager.CreateList(listToStoreEvents, "", new List <string>());
            const string courseIdNotInCatalog = "COMP0101";

            var eventAggregator = new EventAggregator(mockSharepointManager, emptyCourseCatalog, new InMemoryLogger <EventAggregator>());

            StudentEvent eventToStore = new StudentEvent
            {
                CourseID     = courseIdNotInCatalog,
                EventType    = EventType.Attendance,
                ActivityType = "Video",
                ActivityName = "Introductory Lesson",
                Timestamp    = DateTime.UtcNow,
                Student      = new Student {
                    Email = "*****@*****.**", FirstName = "a", LastName = "b", ID = " 0"
                }
            };
            await eventAggregator.ProcessEvent(eventToStore);

            var itemsInSharepointList = await mockSharepointManager.GetItemsFromList(listToStoreEvents);

            Assert.Empty(itemsInSharepointList);
        }
예제 #2
0
        public async Task ProcessEventDoesNotStoreEngagementEventOnSharepoint()
        {
            var    mockSharepointManager = new MockSharepointManager();
            var    courseCatalog         = new MockSharepointCourseCatalog();
            string courseId          = "COMP0101";
            string listToStoreEvents = "Attendance Events";

            courseCatalog.mockCatalog.Add(courseId, new CourseCatalogType {
                ListName = listToStoreEvents, JoinWebUrl = null
            });
            mockSharepointManager.CreateList(listToStoreEvents, "", new List <string>());

            var eventAggregator = new EventAggregator(mockSharepointManager, courseCatalog, new InMemoryLogger <EventAggregator>());

            StudentEvent engagementEvent = new StudentEvent
            {
                CourseID     = courseId,
                EventType    = EventType.Engagement,
                ActivityType = "Video",
                ActivityName = "Introductory Lesson",
                Timestamp    = DateTime.UtcNow,
                Student      = new Student {
                    Email = "*****@*****.**", FirstName = "a", LastName = "b", ID = " 0"
                }
            };
            await eventAggregator.ProcessEvent(engagementEvent);

            var itemsInSharepointList = await mockSharepointManager.GetItemsFromList(listToStoreEvents);

            Assert.Empty(itemsInSharepointList);
        }
예제 #3
0
        public async Task ProcessEventStoresAttendanceEventOnSharepoint()
        {
            var    mockSharepointManager = new MockSharepointManager();
            var    courseCatalog         = new MockSharepointCourseCatalog();
            string courseId          = "COMP0101";
            string listToStoreEvents = "Attendance Events";

            courseCatalog.mockCatalog.Add(courseId, listToStoreEvents);
            mockSharepointManager.CreateList(listToStoreEvents, "", new List <string>());

            var eventAggregator = new EventAggregator(mockSharepointManager, courseCatalog, new InMemoryLogger <EventAggregator>());

            StudentEvent eventToStore = new StudentEvent
            {
                CourseID     = courseId,
                EventType    = EventType.Attendance,
                ActivityType = "Video",
                ActivityName = "Introductory Lesson",
                Timestamp    = DateTime.UtcNow,
                Student      = new Student {
                    Email = "*****@*****.**", FirstName = "a", LastName = "b", ID = " 0"
                }
            };
            await eventAggregator.ProcessEvent(eventToStore);


            var itemsInSharepointList = await mockSharepointManager.GetItemsFromList(listToStoreEvents);

            Assert.Single(itemsInSharepointList);
            var itemInList = itemsInSharepointList[0];

            Assert.Equal(eventToStore.CourseID, (string)itemInList["CourseID"]);
            Assert.Equal(eventToStore.Student.Email, (string)itemInList["StudentEmail"]);
            Assert.Equal(eventToStore.EventType.ToString(), (string)itemInList["EventType"]);
            Assert.Equal(eventToStore.ActivityType, (string)itemInList["ActivityType"]);
            Assert.Equal(eventToStore.ActivityName, (string)itemInList["ActivityName"]);
            Assert.Equal(eventToStore.Timestamp, (DateTime)itemInList["Timestamp"]);
        }