/// <summary> /// Basic CRUD operations test. /// </summary> /// <param name="exchangeService"></param> public static void CreateReadUpdateDeleteMailFolder(ExchangeService exchangeService) { exchangeService.MailboxId = new MailboxId(AppConfig.MailboxA); foreach (MailFolder folder in exchangeService.FindFolders(WellKnownFolderName.Inbox, new FolderView(10))) { folder.Delete(); } MailFolder folder1 = new MailFolder(exchangeService) { DisplayName = "MyTestFolder1" }; Assert.IsNull(folder1.Id); folder1.Save(WellKnownFolderName.Inbox); Assert.IsNotNull(folder1.Id); MailFolder folder2 = new MailFolder(exchangeService); folder2.DisplayName = "MyTestFolder2"; Assert.IsNull(folder2.Id); folder2.Save(WellKnownFolderName.Inbox); Assert.IsNotNull(folder2.Id); Thread.Sleep(5000); folder2 = folder2.Move(folder1.Id); folder1.DisplayName = "NewDisplayName"; folder1.Update(); Assert.AreEqual( "NewDisplayName", folder1.DisplayName); Assert.AreEqual( folder1.Id, folder2.ParentFolderId); folder2.Delete(); Assert.IsNull(folder2.DisplayName); Assert.IsNull(folder2.Id); folder1.Delete(); Assert.IsNull(folder1.DisplayName); Assert.IsNull(folder1.Id); }
public void Test_UpdateMailFolder() { this.RunHttp200WithEmptyResponseBetaEndpoint( (exchangeService) => { // not new folder is created, instead we are mocking updating 'existing' folder. MailFolder mailFolder = new MailFolder(); mailFolder.MailboxId = exchangeService.MailboxId; mailFolder.Service = exchangeService; mailFolder.Id = "BBCC=="; mailFolder.DisplayName = "AbcFolder"; mailFolder.ResetChangeTracking(); Assert.IsNotNull(mailFolder.FolderId); mailFolder.DisplayName = "FolderAbc"; mailFolder.Update(); }, (httpRequestMessage) => { Assert.AreEqual( Exchange.RestServices.HttpWebRequest.PATCH, httpRequestMessage.Method); Uri requestUri = new Uri("https://outlook.office365.com/api/beta/users/[email protected]/mailfolders/BBCC=="); Assert.AreEqual( requestUri, httpRequestMessage.RequestUri); MailFolder deserializedFolder = Deserializer.Instance.Deserialize <MailFolder>( httpRequestMessage.Content.ReadAsStringAsync().Result, null); Assert.AreEqual( deserializedFolder.DisplayName, "FolderAbc"); }); }