public async Task UpdateInMemoryMappingGetsLatestCopyOfUnderlyingSharepointList()
        {
            var courseCatalogListName   = "CourseCatalog";
            SharepointSettings settings = SharepointSettingsWithCourseCatalogName(courseCatalogListName);
            var mockSharepointManager   = new MockSharepointManager();

            mockSharepointManager.CreateList(courseCatalogListName, "", new List <string>());

            string courseIdThatWillBeDeleted = "COMP0100";
            var    itemThatWillBeDeleted     = ListItemWithCourseIdAndListName(courseIdThatWillBeDeleted, "any", "any");
            await mockSharepointManager.AddItemToList(courseCatalogListName, itemThatWillBeDeleted);

            var courseCatalog = new SharepointCourseCatalog(Options.Create(settings), new InMemoryLogger <SharepointCourseCatalog>(), mockSharepointManager);

            // simulate deleting an item from the sharepoint list
            mockSharepointManager.mockEventList[courseCatalogListName].Remove(itemThatWillBeDeleted);
            // simulate adding an item to the sharepoint list
            string courseIdThatWillBeAdded = "COMP0102";
            string expectedListName        = "expectedListName";
            string expectedJoinWebUrl      = "expectedJoinWebUrl";
            await mockSharepointManager.AddItemToList(courseCatalogListName, ListItemWithCourseIdAndListName(courseIdThatWillBeAdded, expectedListName, expectedJoinWebUrl));

            // update the catalog after modifying the underlying sharepoint list
            await courseCatalog.UpdateInMemoryMapping();

            Assert.Throws <KeyNotFoundException>(() => courseCatalog.GetListNameForCourse(courseIdThatWillBeDeleted));
            string actualListNameOfAddedEntry = courseCatalog.GetListNameForCourse(courseIdThatWillBeAdded);

            Assert.Equal(expectedListName, actualListNameOfAddedEntry);
            string actualCourseId = courseCatalog.GetCourseIDForJoinWebURL(expectedJoinWebUrl);

            Assert.Equal(courseIdThatWillBeAdded, actualCourseId);
        }
        private static SharepointSettings SharepointSettingsFromEnv()
        {
            var settings = new SharepointSettings
            {
                SharepointUrl         = Environment.GetEnvironmentVariable("SHAREPOINT_URL"),
                ClientId              = Environment.GetEnvironmentVariable("SHAREPOINT_CLIENT_ID"),
                ClientSecret          = Environment.GetEnvironmentVariable("SHAREPOINT_CLIENT_SECRET"),
                CourseCatalogListName = "defaultName"
                                        // No need for course catalog for this class' testing.
            };

            return(settings);
        }