From 6c938d4abf38c76a7785d93b143bb82c1d8a946a Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Tue, 28 Feb 2023 22:19:08 +0300 Subject: [PATCH] Refactors tests after breaking change --- Microsoft.Graph.Beta.sln | 18 +++++ .../DriveItemRequestBuilderExtensions.cs | 70 +++++++++---------- .../Microsoft.Graph.Beta.csproj | 6 +- .../Requests/Functional/DeltaQueryTests.cs | 30 ++++---- .../Requests/Functional/EventTests.cs | 6 +- .../Requests/Functional/ExcelTests.cs | 10 +-- .../Requests/Functional/ExtensionTests.cs | 3 +- .../Requests/Functional/GroupTests.cs | 3 +- .../Requests/Functional/MailTests.cs | 6 +- .../Requests/Functional/MiscTests.cs | 5 +- .../Requests/Functional/OneDriveTests.cs | 29 ++++---- .../Requests/Functional/OneNoteTests.cs | 18 ++--- .../Requests/Functional/ReportTests.cs | 5 +- .../Requests/Functional/SharePointTests.cs | 9 +-- .../Functional/UserActivitiesTests.cs | 13 ++-- .../Requests/Functional/UserTests.cs | 36 +++++----- .../Requests/Generated/ActionRequestTests.cs | 34 ++++----- .../Generated/FunctionRequestTests.cs | 26 +++---- 18 files changed, 175 insertions(+), 152 deletions(-) diff --git a/Microsoft.Graph.Beta.sln b/Microsoft.Graph.Beta.sln index 4065b4e17d0..fc03980123d 100644 --- a/Microsoft.Graph.Beta.sln +++ b/Microsoft.Graph.Beta.sln @@ -4,6 +4,8 @@ VisualStudioVersion = 17.1.31903.286 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Graph.Beta", "src\Microsoft.Graph\Microsoft.Graph.Beta.csproj", "{660FA73B-987D-4085-A230-1B04F7EAEFBC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Graph.DotnetCore.Test", "tests\Microsoft.Graph.DotnetCore.Test\Microsoft.Graph.DotnetCore.Test.csproj", "{15DE269F-3B76-461C-9954-EC2A8FF9B9E8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,6 +34,22 @@ Global {660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x64.Build.0 = Release|Any CPU {660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x86.ActiveCfg = Release|Any CPU {660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x86.Build.0 = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|ARM.ActiveCfg = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|ARM.Build.0 = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|x64.ActiveCfg = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|x64.Build.0 = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|x86.ActiveCfg = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Debug|x86.Build.0 = Debug|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|Any CPU.Build.0 = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|ARM.ActiveCfg = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|ARM.Build.0 = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|x64.ActiveCfg = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|x64.Build.0 = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|x86.ActiveCfg = Release|Any CPU + {15DE269F-3B76-461C-9954-EC2A8FF9B9E8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Microsoft.Graph/Extensions/DriveItemRequestBuilderExtensions.cs b/src/Microsoft.Graph/Extensions/DriveItemRequestBuilderExtensions.cs index b425071e411..c234c557f35 100644 --- a/src/Microsoft.Graph/Extensions/DriveItemRequestBuilderExtensions.cs +++ b/src/Microsoft.Graph/Extensions/DriveItemRequestBuilderExtensions.cs @@ -1,22 +1,21 @@ -/* -using System; +using System; using System.Linq; using System.Reflection; using Microsoft.Graph.Beta.Drives.Item.Items.Item.Analytics; using Microsoft.Graph.Beta.Drives.Item.Items.Item.Children; using Microsoft.Graph.Beta.Drives.Item.Items.Item.Content; using Microsoft.Graph.Beta.Drives.Item.Items.Item.ListItem; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCheckin; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCheckout; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCopy; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCreateLink; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCreateUploadSession; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphFollow; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphInvite; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphPreview; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphRestore; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphUnfollow; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphValidatePermission; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Checkin; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Checkout; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Copy; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.CreateLink; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.CreateUploadSession; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Follow; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Invite; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Preview; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Restore; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Unfollow; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.ValidatePermission; using Microsoft.Graph.Beta.Drives.Item.Items.Item.Permissions; using Microsoft.Graph.Beta.Drives.Item.Items.Item.Subscriptions; using Microsoft.Graph.Beta.Drives.Item.Items.Item.Thumbnails; @@ -110,12 +109,12 @@ public CustomDriveItemItemRequestBuilder(string rawUrl, IRequestAdapter requestA new AnalyticsRequestBuilder(this._rawUrl + "/analytics", RequestAdapter); } /// Provides operations to call the checkin method. - public new MicrosoftGraphCheckinRequestBuilder MicrosoftGraphCheckin { get => - new MicrosoftGraphCheckinRequestBuilder(this._rawUrl + "/microsoft.graph.checkin", RequestAdapter); + public new CheckinRequestBuilder Checkin { get => + new CheckinRequestBuilder(this._rawUrl + "/microsoft.graph.checkin", RequestAdapter); } /// Provides operations to call the checkout method. - public new MicrosoftGraphCheckoutRequestBuilder MicrosoftGraphCheckout { get => - new MicrosoftGraphCheckoutRequestBuilder(this._rawUrl + "/microsoft.graph.checkout", RequestAdapter); + public new CheckoutRequestBuilder Checkout { get => + new CheckoutRequestBuilder(this._rawUrl + "/microsoft.graph.checkout", RequestAdapter); } /// Provides operations to manage the children property of the microsoft.graph.driveItem entity. public new ChildrenRequestBuilder Children { get => @@ -126,24 +125,24 @@ public CustomDriveItemItemRequestBuilder(string rawUrl, IRequestAdapter requestA new ContentRequestBuilder(this._rawUrl + "/content", RequestAdapter); } /// Provides operations to call the copy method. - public new MicrosoftGraphCopyRequestBuilder MicrosoftGraphCopy { get => - new MicrosoftGraphCopyRequestBuilder(this._rawUrl + "/microsoft.graph.copy", RequestAdapter); + public new CopyRequestBuilder Copy { get => + new CopyRequestBuilder(this._rawUrl + "/microsoft.graph.copy", RequestAdapter); } /// Provides operations to call the createLink method. - public new MicrosoftGraphCreateLinkRequestBuilder MicrosoftGraphCreateLink { get => - new MicrosoftGraphCreateLinkRequestBuilder(this._rawUrl + "/microsoft.graph.createLink", RequestAdapter); + public new CreateLinkRequestBuilder CreateLink { get => + new CreateLinkRequestBuilder(this._rawUrl + "/microsoft.graph.createLink", RequestAdapter); } /// Provides operations to call the createUploadSession method. - public new MicrosoftGraphCreateUploadSessionRequestBuilder MicrosoftGraphCreateUploadSession { get => - new MicrosoftGraphCreateUploadSessionRequestBuilder(this._rawUrl+"/microsoft.graph.createUploadSession" , RequestAdapter); + public new CreateUploadSessionRequestBuilder CreateUploadSession { get => + new CreateUploadSessionRequestBuilder(this._rawUrl+"/microsoft.graph.createUploadSession" , RequestAdapter); } /// Provides operations to call the follow method. - public new MicrosoftGraphFollowRequestBuilder MicrosoftGraphFollow { get => - new MicrosoftGraphFollowRequestBuilder(this._rawUrl + "/microsoft.graph.follow", RequestAdapter); + public new FollowRequestBuilder Follow { get => + new FollowRequestBuilder(this._rawUrl + "/microsoft.graph.follow", RequestAdapter); } /// Provides operations to call the invite method. - public new MicrosoftGraphInviteRequestBuilder MicrosoftGraphInvite { get => - new MicrosoftGraphInviteRequestBuilder(this._rawUrl + "/microsoft.graph.invite", RequestAdapter); + public new InviteRequestBuilder Invite { get => + new InviteRequestBuilder(this._rawUrl + "/microsoft.graph.invite", RequestAdapter); } /// Provides operations to manage the listItem property of the microsoft.graph.driveItem entity. public new ListItemRequestBuilder ListItem { get => @@ -154,14 +153,14 @@ public CustomDriveItemItemRequestBuilder(string rawUrl, IRequestAdapter requestA new PermissionsRequestBuilder(this._rawUrl+"/permissions", RequestAdapter); } /// Provides operations to call the preview method. - public new MicrosoftGraphPreviewRequestBuilder MicrosoftGraphPreview { get => - new MicrosoftGraphPreviewRequestBuilder(this._rawUrl+"/microsoft.graph.preview", RequestAdapter); + public new PreviewRequestBuilder Preview { get => + new PreviewRequestBuilder(this._rawUrl+"/microsoft.graph.preview", RequestAdapter); } /// The request adapter to use to execute the requests. private IRequestAdapter RequestAdapter { get; set; } /// Provides operations to call the restore method. - public new MicrosoftGraphRestoreRequestBuilder MicrosoftGraphRestore { get => - new MicrosoftGraphRestoreRequestBuilder(this._rawUrl+"/microsoft.graph.restore", RequestAdapter); + public new RestoreRequestBuilder Restore { get => + new RestoreRequestBuilder(this._rawUrl+"/microsoft.graph.restore", RequestAdapter); } /// Provides operations to manage the subscriptions property of the microsoft.graph.driveItem entity. public new SubscriptionsRequestBuilder Subscriptions { get => @@ -172,16 +171,15 @@ public CustomDriveItemItemRequestBuilder(string rawUrl, IRequestAdapter requestA new ThumbnailsRequestBuilder(this._rawUrl+"/thumbnails", RequestAdapter); } /// Provides operations to call the unfollow method. - public new MicrosoftGraphUnfollowRequestBuilder MicrosoftGraphUnfollow { get => - new MicrosoftGraphUnfollowRequestBuilder(this._rawUrl+"/microsoft.graph.unfollow", RequestAdapter); + public new UnfollowRequestBuilder Unfollow { get => + new UnfollowRequestBuilder(this._rawUrl+"/microsoft.graph.unfollow", RequestAdapter); } /// Provides operations to call the validatePermission method. - public new MicrosoftGraphValidatePermissionRequestBuilder MicrosoftGraphValidatePermission { get => - new MicrosoftGraphValidatePermissionRequestBuilder(this._rawUrl+"/microsoft.graph.validatePermission", RequestAdapter); + public new ValidatePermissionRequestBuilder ValidatePermission { get => + new ValidatePermissionRequestBuilder(this._rawUrl+"/microsoft.graph.validatePermission", RequestAdapter); } /// Provides operations to manage the versions property of the microsoft.graph.driveItem entity. public new VersionsRequestBuilder Versions { get => new VersionsRequestBuilder(this._rawUrl+"/versions", RequestAdapter); } } -*/ diff --git a/src/Microsoft.Graph/Microsoft.Graph.Beta.csproj b/src/Microsoft.Graph/Microsoft.Graph.Beta.csproj index 5e095d05c09..3f01dcc1a28 100644 --- a/src/Microsoft.Graph/Microsoft.Graph.Beta.csproj +++ b/src/Microsoft.Graph/Microsoft.Graph.Beta.csproj @@ -23,10 +23,10 @@ true - [Breaking] Namespace and Request Builder renaming to align to paths defined in metadata (https://github.com/microsoft/kiota/issues/2209) -- Latest metadata updates from 7th February 2023 snapshot. +- Latest metadata updates from 28th February 2023 snapshot. - 5.19.0 + 5.20.0 @@ -67,7 +67,7 @@ - + diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/DeltaQueryTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/DeltaQueryTests.cs index 3691eb9f644..b2fa898079d 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/DeltaQueryTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/DeltaQueryTests.cs @@ -15,18 +15,18 @@ public class DeltaQueryTests: GraphTestBase public async Task DeltaLinkDriveItem() { // Get our first delta page. - var driveItemDeltaCollectionPage = await graphClient.Drives["driveId"].Items[""].MicrosoftGraphDelta.GetAsync(); + var driveItemDeltaCollectionPage = await graphClient.Drives["driveId"].Items[""].Delta.GetAsync(); // Go through all of the delta pages so that we can get the delta link on the last page. while (driveItemDeltaCollectionPage.OdataNextLink != null) { - driveItemDeltaCollectionPage = await new Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(driveItemDeltaCollectionPage.OdataNextLink, graphClient.RequestAdapter).GetAsync(); + driveItemDeltaCollectionPage = await new Microsoft.Graph.Beta.Drives.Item.Items.Item.Delta.DeltaRequestBuilder(driveItemDeltaCollectionPage.OdataNextLink, graphClient.RequestAdapter).GetAsync(); } // Now let's use the deltalink to make sure there aren't any changes. There shouldn't be. if (driveItemDeltaCollectionPage.OdataDeltaLink != null) { - driveItemDeltaCollectionPage = await new Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(driveItemDeltaCollectionPage.OdataDeltaLink, graphClient.RequestAdapter).GetAsync(); + driveItemDeltaCollectionPage = await new Microsoft.Graph.Beta.Drives.Item.Items.Item.Delta.DeltaRequestBuilder(driveItemDeltaCollectionPage.OdataDeltaLink, graphClient.RequestAdapter).GetAsync(); } Assert.Empty(driveItemDeltaCollectionPage.Value); @@ -38,7 +38,7 @@ public async Task DeltaLinkDriveItem() // Now let's use the deltalink to make sure there aren't any changes. if (driveItemDeltaCollectionPage.OdataDeltaLink != null) { - driveItemDeltaCollectionPage = await new Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(driveItemDeltaCollectionPage.OdataDeltaLink, graphClient.RequestAdapter).GetAsync(); + driveItemDeltaCollectionPage = await new Microsoft.Graph.Beta.Drives.Item.Items.Item.Delta.DeltaRequestBuilder(driveItemDeltaCollectionPage.OdataDeltaLink, graphClient.RequestAdapter).GetAsync(); } // We expect two changes, one new item, and the root folder will have a change. @@ -54,18 +54,18 @@ public async Task DeltaLinkDriveItem() public async Task DeltaLinkMessages() { // Get our first delta page. - var messagesDeltaCollectionPage = await graphClient.Me.MailFolders["inbox"].Messages.MicrosoftGraphDelta.GetAsync(); + var messagesDeltaCollectionPage = await graphClient.Me.MailFolders["inbox"].Messages.Delta.GetAsync(); // Go through all of the delta pages so that we can get the delta link on the last page. while (messagesDeltaCollectionPage.OdataNextLink != null) { - messagesDeltaCollectionPage = await new Microsoft.Graph.Beta.Me.MailFolders.Item.Messages.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(messagesDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); + messagesDeltaCollectionPage = await new Microsoft.Graph.Beta.Me.MailFolders.Item.Messages.Delta.DeltaRequestBuilder(messagesDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); } // Now let's use the deltalink to make sure there aren't any changes. There shouldn't be. if (messagesDeltaCollectionPage.OdataDeltaLink != null) { - messagesDeltaCollectionPage = await new Microsoft.Graph.Beta.Me.MailFolders.Item.Messages.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(messagesDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); + messagesDeltaCollectionPage = await new Microsoft.Graph.Beta.Me.MailFolders.Item.Messages.Delta.DeltaRequestBuilder(messagesDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); } Assert.Empty(messagesDeltaCollectionPage.Value); @@ -75,7 +75,7 @@ public async Task DeltaLinkMessages() // Now let's use the deltalink to make sure there aren't any changes. We expect to see a new message. if (messagesDeltaCollectionPage.OdataDeltaLink != null) { - messagesDeltaCollectionPage = await new Microsoft.Graph.Beta.Me.MailFolders.Item.Messages.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(messagesDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); + messagesDeltaCollectionPage = await new Microsoft.Graph.Beta.Me.MailFolders.Item.Messages.Delta.DeltaRequestBuilder(messagesDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); } // We expect two changes, one new item, and the root folder will have a change. @@ -86,20 +86,20 @@ public async Task DeltaLinkMessages() public async Task UserDeltaLink() { // Get our first delta page. - var userDeltaCollectionPage = await graphClient.Users.MicrosoftGraphDelta.GetAsync(); + var userDeltaCollectionPage = await graphClient.Users.Delta.GetAsync(); //var userDeltaCollectionPage = userDeltaCollectionPageResult.Value; // Go through all of the delta pages so that we can get the delta link on the last page. while (userDeltaCollectionPage.OdataNextLink != null) { - userDeltaCollectionPage = await new Microsoft.Graph.Beta.Users.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(userDeltaCollectionPage.OdataNextLink, graphClient.RequestAdapter).GetAsync(); + userDeltaCollectionPage = await new Microsoft.Graph.Beta.Users.Delta.DeltaRequestBuilder(userDeltaCollectionPage.OdataNextLink, graphClient.RequestAdapter).GetAsync(); } // Now let's use the deltalink to make sure there aren't any changes. We won't test this collection // since other tests could be making changes to the users in the org. if (userDeltaCollectionPage.OdataDeltaLink != null) { - userDeltaCollectionPage = await new Microsoft.Graph.Beta.Users.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(userDeltaCollectionPage.OdataDeltaLink, graphClient.RequestAdapter).GetAsync(); + userDeltaCollectionPage = await new Microsoft.Graph.Beta.Users.Delta.DeltaRequestBuilder(userDeltaCollectionPage.OdataDeltaLink, graphClient.RequestAdapter).GetAsync(); } } @@ -107,18 +107,18 @@ public async Task UserDeltaLink() public async Task GroupDeltaLink() { // Get our first delta page. - var groupDeltaCollectionPage = await graphClient.Groups.MicrosoftGraphDelta.GetAsync(); + var groupDeltaCollectionPage = await graphClient.Groups.Delta.GetAsync(); // Go through all of the delta pages so that we can get the delta link on the last page. while (groupDeltaCollectionPage.OdataNextLink != null) { - groupDeltaCollectionPage = await new Microsoft.Graph.Beta.Groups.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(groupDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); + groupDeltaCollectionPage = await new Microsoft.Graph.Beta.Groups.Delta.DeltaRequestBuilder(groupDeltaCollectionPage.OdataNextLink,graphClient.RequestAdapter).GetAsync(); } // Now let's use the deltalink to make sure there aren't any changes. if (groupDeltaCollectionPage.OdataDeltaLink != null) { - groupDeltaCollectionPage = await new Microsoft.Graph.Beta.Groups.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(groupDeltaCollectionPage.OdataDeltaLink,graphClient.RequestAdapter).GetAsync(); + groupDeltaCollectionPage = await new Microsoft.Graph.Beta.Groups.Delta.DeltaRequestBuilder(groupDeltaCollectionPage.OdataDeltaLink,graphClient.RequestAdapter).GetAsync(); // This could be false in case a change has occurred to a group since the last deltapage. Assert.True((groupDeltaCollectionPage.Value.Count == 0), "groupDeltaCollectionPage has unexpected entry."); @@ -148,7 +148,7 @@ public async Task GroupDeltaLink() // Call with the deltalink. We have to wait since there is some latency between the time that the // group is created and the time when the delta is registered. await Task.Delay(10000); - groupDeltaCollectionPage = await new Microsoft.Graph.Beta.Groups.MicrosoftGraphDelta.MicrosoftGraphDeltaRequestBuilder(groupDeltaCollectionPage.OdataDeltaLink,graphClient.RequestAdapter).GetAsync(); + groupDeltaCollectionPage = await new Microsoft.Graph.Beta.Groups.Delta.DeltaRequestBuilder(groupDeltaCollectionPage.OdataDeltaLink,graphClient.RequestAdapter).GetAsync(); Assert.True((groupDeltaCollectionPage.Value.Count == 1)); diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/EventTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/EventTests.cs index b9c9f0688d2..51d13ad8452 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/EventTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/EventTests.cs @@ -8,7 +8,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using System.Collections.Generic; using System.Threading.Tasks; using Xunit; - using Microsoft.Graph.Beta.Me.MicrosoftGraphFindMeetingTimes; + using Microsoft.Graph.Beta.Me.FindMeetingTimes; using Microsoft.Graph.Beta.Models; public class EventTests : GraphTestBase @@ -100,7 +100,7 @@ public async Task EventFindMeetingsTimes() IsOrganizerOptional = true, ReturnSuggestionReasons = false }; - MeetingTimeSuggestionsResult resultsFromISO8601 = await graphClient.Me.MicrosoftGraphFindMeetingTimes.PostAsync(requestBody1); + MeetingTimeSuggestionsResult resultsFromISO8601 = await graphClient.Me.FindMeetingTimes.PostAsync(requestBody1); var requestBody = new FindMeetingTimesPostRequestBody { @@ -109,7 +109,7 @@ public async Task EventFindMeetingsTimes() MinimumAttendeePercentage = 10.0, MaxCandidates = 2 }; - MeetingTimeSuggestionsResult resultsFromTimeSpan = await graphClient.Me.MicrosoftGraphFindMeetingTimes.PostAsync(requestBody); + MeetingTimeSuggestionsResult resultsFromTimeSpan = await graphClient.Me.FindMeetingTimes.PostAsync(requestBody); Assert.NotNull(resultsFromTimeSpan); // Make sure that our custom serialization results are the same for both scenarios. diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExcelTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExcelTests.cs index a19534fd290..72507ff5236 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExcelTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExcelTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ @@ -14,10 +14,12 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using System.Threading.Tasks; using Xunit; using Microsoft.Graph.Beta.Models; + using Microsoft.Graph.Beta.Models.ODataErrors; + /// /// The tests in this class cover the Excel REST API. /// - + public class ExcelTests : GraphTestBase { [Fact (Skip = "No CI set up for functional tests")] @@ -33,7 +35,7 @@ private async Task OneDriveSearchForTestFile(string fileName = "_excelTestResour { // Check that this item hasn't already been created. // https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_search - var searchResults = await graphClient.Drives["driveId"].Items[""].MicrosoftGraphSearchWithQ(fileName).GetAsync(); + var searchResults = await graphClient.Drives["driveId"].Items[""].SearchWithQ(fileName).GetAsync(); foreach (var r in searchResults.Value) { if (r.Name != fileName) @@ -93,7 +95,7 @@ internal async Task OneDriveDeleteTestFile(string fileId, int delayInMillisecond // https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_delete await graphClient.Drives["driveId"].Items[fileId].DeleteAsync(requestConfiguration => requestConfiguration.Headers.Add("if-match","*")); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { if (e.Error.Code == "resourceModified") Assert.True(false, "Error code: " + e.Error.Code + ", message: " + e.Error.Message); diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExtensionTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExtensionTests.cs index 0a11552275f..bf2ee22f3df 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExtensionTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ExtensionTests.cs @@ -5,6 +5,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { using Microsoft.Graph.Beta.Models; + using Microsoft.Graph.Beta.Models.ODataErrors; using System.Collections.Generic; using System.Threading.Tasks; using Xunit; @@ -26,7 +27,7 @@ public async Task ExtensionAddRoamingProfile() Assert.NotNull(e); Assert.Equal(openTypeExtension.ExtensionName, e.Id); // The extension name and identifier should match. } - catch (ServiceException e) + catch (ODataError e) { if (e.Error.Message == "An extension already exists with given id.") { diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/GroupTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/GroupTests.cs index 9d72633ceaf..5a4baa44336 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/GroupTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/GroupTests.cs @@ -2,6 +2,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { using Microsoft.Graph.Beta.Models; + using Microsoft.Graph.Beta.Models.ODataErrors; using System.Threading.Tasks; using Xunit; @@ -31,7 +32,7 @@ public async Task GroupCreateTeam() //TODO should be PUT await graphClient.Groups[groupPage.Value[8].Id].Team.PatchAsync(team); } - catch (ServiceException e) + catch (ODataError e) { Assert.True(false, e.Error.ToString()); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MailTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MailTests.cs index 3a9ce9f7233..f00f8f73d97 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MailTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MailTests.cs @@ -5,7 +5,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { using Microsoft.Graph.Beta.Models; - using Microsoft.Graph.Beta.Me.MicrosoftGraphSendMail; + using Microsoft.Graph.Beta.Me.SendMail; using Microsoft.Graph.DotnetCore.Test.Requests.Functional.Resources; using System; using System.Collections.Generic; @@ -59,7 +59,7 @@ public async System.Threading.Tasks.Task MailSendMail() SaveToSentItems = true }; // Send email to the test user. - await graphClient.Me.MicrosoftGraphSendMail.PostAsync(sendMailBody); + await graphClient.Me.SendMail.PostAsync(sendMailBody); // Check the we found the sent email in the sent items folder. var mailFolderMessagesCollectionPage = await graphClient.Me.MailFolders["sentitems"].Messages.GetAsync(requestConfiguration => requestConfiguration.QueryParameters.Filter = "Subject eq '" + message.Subject + "'"); @@ -97,7 +97,7 @@ public async System.Threading.Tasks.Task MailSendMailWithFileAttachment() Message = message, SaveToSentItems = true }; - await graphClient.Me.MicrosoftGraphSendMail.PostAsync(sendMailBody); + await graphClient.Me.SendMail.PostAsync(sendMailBody); } catch (ApiException e) { diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MiscTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MiscTests.cs index 78307cf3126..926f13763b8 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MiscTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/MiscTests.cs @@ -5,7 +5,8 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using System.Threading.Tasks; using Xunit; using Microsoft.Graph.Beta.Models; - + using Microsoft.Graph.Beta.Models.ODataErrors; + public class MiscTests: GraphTestBase { /// @@ -33,7 +34,7 @@ public async Task GroupCreateExtension() // Delete the extension. Results in a call to the service. await graphClient.Groups[groupPage.Value[0].Id].Extensions["com.contoso.trackingKey"].DeleteAsync(); } - catch (ServiceException e) + catch (ODataError e) { Assert.True(false, e.Error.ToString()); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneDriveTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneDriveTests.cs index 43859531a62..c8604f7eb28 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneDriveTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneDriveTests.cs @@ -3,8 +3,8 @@ // ------------------------------------------------------------------------------ using Microsoft.Graph.Beta.Drives.Item.Items.Item.Children; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCreateLink; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphInvite; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.CreateLink; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.Invite; namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { @@ -17,14 +17,15 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using Microsoft.Graph.Beta.Drives.Item.Items.Item.Permissions; using Microsoft.Graph.Beta.Models; using Microsoft.Graph.Beta; - + using Microsoft.Graph.Beta.Models.ODataErrors; + public class OneDriveTests : GraphTestBase { [Fact(Skip = "No CI set up for functional tests")] public async Task OneDriveSharedWithMe() { - var sharedDriveItems = await graphClient.Drives["driveId"].MicrosoftGraphSharedWithMe.GetAsync(); + var sharedDriveItems = await graphClient.Drives["driveId"].SharedWithMe.GetAsync(); var permissionsPage = await graphClient.Drives["driveId"].Items[sharedDriveItems.Value[0].Id].Permissions.GetAsync(); var permissions = new List(); permissions.AddRange(permissionsPage.Value); @@ -127,7 +128,7 @@ public async Task OneDriveDownloadLargeFile() } } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -152,7 +153,7 @@ public async Task OneDriveNextPageRequest() driveItems.AddRange(driveItemsPage.Value); } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, "Something happened, check out a trace. Error code: " + e.Error.Code); } @@ -178,7 +179,7 @@ public async Task OneDriveGetContent() } } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, "Something happened, check out a trace. Error code: " + e.Error.Code); } @@ -219,7 +220,7 @@ public async Task OneDriveGetSetPermissions() } } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, "Something happened, check out a trace. Error code: " + e.Error.Code); } @@ -233,13 +234,13 @@ public async Task OneDriveSearchFile() try { // http://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_search - var driveItems = await graphClient.Drives["driveId"].MicrosoftGraphSearchWithQ("employee services").GetAsync(); + var driveItems = await graphClient.Drives["driveId"].SearchWithQ("employee services").GetAsync(); // Expecting two results. Assert.Equal(2, driveItems.Value.Count); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, "Something happened, check out a trace. Error code: " + e.Error.Code); } @@ -260,7 +261,7 @@ public async Task OneDriveCreateSharingLink() var requestBody = new CreateLinkPostRequestBody { Type = "edit", Scope = "organization" }; var permission = await graphClient.Drives["driveId"].Root .ItemWithPath(itemToShare.Value[0].Name) - .MicrosoftGraphCreateLink + .CreateLink .PostAsync(requestBody); Assert.Equal("organization", permission.Link.Scope); @@ -268,7 +269,7 @@ public async Task OneDriveCreateSharingLink() Assert.NotNull(permission.Link.WebUrl); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, "Something happened, check out a trace. Error code: " + e.Error.Code); } @@ -313,12 +314,12 @@ public async Task OneDriveInvite() var inviteCollection = await graphClient.Drives["driveId"] .Root .ItemWithPath(itemToShare.Value[0].Name) - .MicrosoftGraphInvite + .Invite .PostAsync(invitePostBody); Assert.Equal("Alex Wilber", inviteCollection.Value[0].GrantedTo.User.DisplayName); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, "Something happened, check out a trace. Error code: " + e.Error.Code); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneNoteTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneNoteTests.cs index 12e2003ae5c..34f2fb36e65 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneNoteTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneNoteTests.cs @@ -13,6 +13,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using System.Collections.Generic; using System.Net.Http.Headers; using Microsoft.Graph.DotnetCore.Test.Requests.Functional.Resources; + using Microsoft.Graph.Beta.Models.ODataErrors; public class OneNoteTests : GraphTestBase { @@ -228,7 +229,7 @@ public async Task OneNotePagePreview() OnenotePagePreview pagePreview = await graphClient.Me .Onenote .Pages[pageId] - .MicrosoftGraphPreview + .Preview .GetAsync(); Assert.NotNull(pagePreview); @@ -367,12 +368,7 @@ public async Task OneNoteAddPageHtmlWorkaround() await TestPageCleanUp(); } else - throw new ServiceException( - new Error - { - Code = response.StatusCode.ToString(), - Message = await response.Content.ReadAsStringAsync() - }); + throw new ServiceException(await response.Content.ReadAsStringAsync()); } catch (ApiException e) { @@ -427,7 +423,7 @@ public async Task OneNoteAddPageHtmlWithStreamWorkaround() await TestPageCleanUp(); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Error code: {e.Error.Code}"); } @@ -493,7 +489,7 @@ public async Task OneNoteAddPageMultipartWorkaround() await TestPageCleanUp(); } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Error code: {e.Error.Code}"); } @@ -557,7 +553,7 @@ public async Task OneNoteUpdatePage() // Send the request and get the response. await graphClient.RequestAdapter.SendNoContentAsync(requestInformation); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Error code: {e.Error.Code}"); } @@ -679,7 +675,7 @@ public async Task OneNoteAddPageWithMultipart() await TestPageCleanUp(); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Error code: {e.Error.Code}"); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ReportTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ReportTests.cs index 7521212b49a..3f263ecc300 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ReportTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/ReportTests.cs @@ -6,6 +6,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { using System.IO; using System.Threading.Tasks; + using Microsoft.Graph.Beta.Models.ODataErrors; using Xunit; /// /// Ad hoc functional tests to make sure that the Reports API works. @@ -20,7 +21,7 @@ public async Task ReportingGetUserCounts() try { // Create the request message. - var getOffice365ActiveUserCountsRequest = graphClient.Reports.MicrosoftGraphGetOffice365ActiveUserCountsWithPeriod("D7").ToGetRequestInformation(); + var getOffice365ActiveUserCountsRequest = graphClient.Reports.GetOffice365ActiveUserCountsWithPeriod("D7").ToGetRequestInformation(); // Send the request and get the response. It will automatically follow the redirect to get the Report file. var responseStream = await graphClient.RequestAdapter.SendPrimitiveAsync(getOffice365ActiveUserCountsRequest); @@ -34,7 +35,7 @@ public async Task ReportingGetUserCounts() Assert.Contains("Exchange", csvReportFile); Assert.Contains("SharePoint", csvReportFile); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/SharePointTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/SharePointTests.cs index a93d1892c0a..e15de3f9739 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/SharePointTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/SharePointTests.cs @@ -5,6 +5,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { using Microsoft.Graph.Beta.Models; + using Microsoft.Graph.Beta.Models.ODataErrors; using System.Threading.Tasks; using Xunit; public class Given_a_valid_SharePoint_Site : GraphTestBase @@ -22,7 +23,7 @@ public async Task It_searches_the_SharePoint_Site_and_returns_results() Assert.True(siteSearchResults.Value.Count > 0); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -45,7 +46,7 @@ public async Task It_gets_the_sites_drives() Assert.True(drives.Value.Count > 0); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -79,7 +80,7 @@ public async Task It_gets_the_sites_drives_root_children() // Assert.True(library.Count > 0); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -97,7 +98,7 @@ public async Task It_gets_a_site_by_URL() Assert.NotNull(site); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserActivitiesTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserActivitiesTests.cs index 519f662ef86..a8cc26cf5b7 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserActivitiesTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserActivitiesTests.cs @@ -9,6 +9,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using System.Threading.Tasks; using Xunit; using Microsoft.Graph.Beta.Models; + using Microsoft.Graph.Beta.Models.ODataErrors; public class UserActivitiesTests : GraphTestBase { @@ -72,7 +73,7 @@ public async Task ActivitiesCreateActivityAndGetBack() Assert.True(false, "Ids not equal in create and get responses"); } } - catch (ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -115,7 +116,7 @@ public async Task ActivitiesCreateHistoryAndGetBack() Assert.False(true, "History ids not equal in create and get responses"); } } - catch (ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -144,7 +145,7 @@ public async Task ActivitiesGetRecentActivities() // Get recent user activities //var getRecentResponse = await graphClient.Me.Activities.Recent().GetAsync(requestConfiguration => requestConfiguration.QueryParameters.Expand = new string[] { "historyItems" }); - var getRecentResponse = await graphClient.Me.Activities.MicrosoftGraphRecent.GetAsync(); + var getRecentResponse = await graphClient.Me.Activities.Recent.GetAsync(); Assert.NotNull(getRecentResponse); @@ -159,7 +160,7 @@ public async Task ActivitiesGetRecentActivities() Assert.False(true, "History ids not equal in create and get responses"); } } - catch (ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -192,7 +193,7 @@ public async Task ActivitiesDeleteActivityAndGetBack() Assert.False(true, "Activity has not been deleted"); } } - catch (ServiceException e) + catch (ODataError e) { Assert.False(true, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -239,7 +240,7 @@ public async Task ActivitiesDeleteHistoryAndGetBack() Assert.True(false, "History ids not equal in create and get responses"); } } - catch (ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserTests.cs index 7f456d0dbc9..ccd82c4b281 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/UserTests.cs @@ -4,9 +4,9 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional { - using Microsoft.Graph.Beta.Me.MicrosoftGraphGetMailTips; - using Microsoft.Graph.Beta.Me.MicrosoftGraphGetMemberGroups; - using AssignLicensePostRequestBody = Microsoft.Graph.Beta.Me.MicrosoftGraphAssignLicense.AssignLicensePostRequestBody; + using Microsoft.Graph.Beta.Me.GetMailTips; + using Microsoft.Graph.Beta.Me.GetMemberGroups; + using AssignLicensePostRequestBody = Microsoft.Graph.Beta.Me.AssignLicense.AssignLicensePostRequestBody; using Microsoft.Graph.DotnetCore.Test.Requests.Functional.Resources; using Microsoft.Graph.Beta.Models; using System; @@ -14,6 +14,8 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional using System.IO; using System.Threading.Tasks; using Xunit; + using Microsoft.Graph.Beta.Models.ODataErrors; + public class UserTests : GraphTestBase { [Fact(Skip = "No CI set up for functional tests - add email addresses to run this test.")] @@ -34,7 +36,7 @@ public async Task UserGetMailtipsTestEnumFlags() { EmailAddresses = emailAddresses, MailTipsOptions = mailTipsOptions }; - var mailTipsCollectionPage = await graphClient.Me.MicrosoftGraphGetMailTips.PostAsync(requestBody); + var mailTipsCollectionPage = await graphClient.Me.GetMailTips.PostAsync(requestBody); foreach (var mt in mailTipsCollectionPage.Value) { @@ -182,7 +184,7 @@ public async Task UserFilterStartsWith() Assert.StartsWith("A", u.DisplayName, StringComparison.OrdinalIgnoreCase); } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -201,7 +203,7 @@ public async Task UserGetPhoto() Assert.NotNull(originalPhoto); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { if (e.Error.Code == "ErrorItemNotFound") { @@ -228,7 +230,7 @@ public async Task UserUpdatePhoto() await graphClient.Me.Photo.Content.PutAsync(ms); } } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened, check out a trace. Error code: {e.Error.Code}"); } @@ -243,7 +245,7 @@ public async Task UserGetUser() var user = await graphClient.Me.GetAsync(); Assert.NotNull(user.UserPrincipalName); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened. Error code: {e.Error.Code}"); } @@ -259,7 +261,7 @@ public async Task UserGetManager() Assert.NotNull(managerDirObj); Assert.False(managerDirObj.DisplayName == "", "The display name of the user's manager is not set."); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened. Error code: {e.Error.Code}"); } @@ -284,7 +286,7 @@ public async Task UserUpdateManager() await graphClient.Me.Manager.Ref.PutAsync(reference); Assert.NotNull(managerDirObj); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened. Error code: {e.Error.Code}"); } @@ -301,11 +303,11 @@ public async Task UserAssignLicense() AddLicenses = new List(), RemoveLicenses = new () }; - var user = await graphClient.Me.MicrosoftGraphAssignLicense.PostAsync(requestBody); + var user = await graphClient.Me.AssignLicense.PostAsync(requestBody); Assert.Null(user); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.Equal("Request_BadRequest", e.Error.Code); } @@ -320,7 +322,7 @@ public async Task UserGetMemberGroups_SecurityEnabledOnly_ValueSet() { try { - var getMemberGroupsRequest = graphClient.Me.MicrosoftGraphGetMemberGroups; + var getMemberGroupsRequest = graphClient.Me.GetMemberGroups; var requestBody = new GetMemberGroupsPostRequestBody { SecurityEnabledOnly = true @@ -331,7 +333,7 @@ public async Task UserGetMemberGroups_SecurityEnabledOnly_ValueSet() Assert.Equal("POST", getMemberGroupsRequest.ToPostRequestInformation(requestBody).HttpMethod.ToString()); Assert.True(requestBody.SecurityEnabledOnly.Value); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened. Error code: {e.Error.Code}"); } @@ -346,11 +348,11 @@ public async Task UserGetMemberGroups_SecurityEnabledOnly_ValueNotSet() { try { - var getMemberGroupsRequest = graphClient.Me.MicrosoftGraphGetMemberGroups; + var getMemberGroupsRequest = graphClient.Me.GetMemberGroups; var requestBody = new GetMemberGroupsPostRequestBody(); var directoryObjectGetMemberGroupsCollectionPage = await getMemberGroupsRequest.PostAsync(requestBody); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.Equal("Request_BadRequest", e.Error.Code); } @@ -381,7 +383,7 @@ public async Task UpdateUser() // Update the user back to me. await graphClient.Users[me.UserPrincipalName].PatchAsync(oldMe); } - catch (Microsoft.Graph.ServiceException e) + catch (ODataError e) { Assert.True(false, $"Something happened. Error code: {e.Error.Code}"); } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/ActionRequestTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/ActionRequestTests.cs index 6080d3f6506..21b7bb04cd7 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/ActionRequestTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/ActionRequestTests.cs @@ -9,10 +9,10 @@ using System.Threading.Tasks; using Microsoft.Graph.Beta; using Microsoft.Graph.DotnetCore.Test.Mocks; -using Microsoft.Graph.Beta.Drives.Item.Items.Item.MicrosoftGraphCreateLink; -using Microsoft.Graph.Beta.Me.MicrosoftGraphAssignLicense; -using Microsoft.Graph.Beta.Me.MicrosoftGraphCheckMemberGroups; -using Microsoft.Graph.Beta.Me.MicrosoftGraphGetMemberGroups; +using Microsoft.Graph.Beta.Drives.Item.Items.Item.CreateLink; +using Microsoft.Graph.Beta.Me.AssignLicense; +using Microsoft.Graph.Beta.Me.CheckMemberGroups; +using Microsoft.Graph.Beta.Me.GetMemberGroups; using Microsoft.Graph.Beta.Models; using Microsoft.Kiota.Abstractions; using Microsoft.Kiota.Abstractions.Serialization; @@ -30,7 +30,7 @@ public class ActionRequestTests public void MultipleRequiredParameters() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); - var expectedRequestUrl = $"{string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")}/me/microsoft.graph.assignLicense"; + var expectedRequestUrl = $"{string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")}/me/assignLicense"; var addLicenses = new List { new AssignedLicense() }; @@ -40,7 +40,7 @@ public void MultipleRequiredParameters() RemoveLicenses = new () }; - var requestInformation = graphServiceClient.Me.MicrosoftGraphAssignLicense.ToPostRequestInformation(requestBody); + var requestInformation = graphServiceClient.Me.AssignLicense.ToPostRequestInformation(requestBody); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -53,10 +53,10 @@ public void MultipleRequiredParameters() public void OptionalParameterWithNonNullableType_NullValue() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); - var expectedRequestUrl = $"{string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")}/me/microsoft.graph.getMemberGroups"; + var expectedRequestUrl = $"{string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")}/me/getMemberGroups"; var requestBody = new GetMemberGroupsPostRequestBody { }; - var requestInformation = graphServiceClient.Me.MicrosoftGraphGetMemberGroups.ToPostRequestInformation(requestBody); + var requestInformation = graphServiceClient.Me.GetMemberGroups.ToPostRequestInformation(requestBody); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -70,10 +70,10 @@ public void OptionalParameterWithNonNullableType_NullValue() public void OptionalParameterWithNonNullableType_ValueSet() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); - var expectedRequestUrl = string.Format("{0}/me/microsoft.graph.getMemberGroups", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var expectedRequestUrl = string.Format("{0}/me/getMemberGroups", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); var requestBody = new GetMemberGroupsPostRequestBody { SecurityEnabledOnly = true}; - var requestInformation = graphServiceClient.Me.MicrosoftGraphGetMemberGroups.ToPostRequestInformation(requestBody); + var requestInformation = graphServiceClient.Me.GetMemberGroups.ToPostRequestInformation(requestBody); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -88,9 +88,9 @@ public void NoParameters() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); var messageId = "messageId"; - var expectedRequestUrl = string.Format("{0}/me/mailFolders/Drafts/messages/{1}/microsoft.graph.send", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta"), messageId); + var expectedRequestUrl = string.Format("{0}/me/mailFolders/Drafts/messages/{1}/send", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta"), messageId); - var requestInformation = graphServiceClient.Me.MailFolders["Drafts"].Messages[messageId].MicrosoftGraphSend.ToPostRequestInformation(); + var requestInformation = graphServiceClient.Me.MailFolders["Drafts"].Messages[messageId].Send.ToPostRequestInformation(); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -106,7 +106,7 @@ public void MultipleRequiredParameters_FirstParameterNull() var graphServiceClient = new GraphServiceClient(mockRequestAdapter.Object); var removeLicenses = new List { new Guid() }; - Assert.ThrowsAsync(() => graphServiceClient.Me.MicrosoftGraphAssignLicense.PostAsync(null)); + Assert.ThrowsAsync(() => graphServiceClient.Me.AssignLicense.PostAsync(null)); } /// @@ -121,7 +121,7 @@ public async System.Threading.Tasks.Task PostAsync_CollectionOfPrimitivesReturnT var nextQueryKey = "key"; var nextQueryValue = "value"; - var requestUrl = string.Format("{0}/me/microsoft.graph.checkMemberGroups", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var requestUrl = string.Format("{0}/me/checkMemberGroups", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); var nextPageRequestUrl = string.Format("{0}?{1}={2}", requestUrl, nextQueryKey, nextQueryValue); var checkMemberGroupsCollectionPage = new List() @@ -148,7 +148,7 @@ public async System.Threading.Tasks.Task PostAsync_CollectionOfPrimitivesReturnT { GroupIds = new List() }; - var returnedCollectionPage = await graphServiceClient.Me.MicrosoftGraphCheckMemberGroups.PostAsync(requestBody); + var returnedCollectionPage = await graphServiceClient.Me.CheckMemberGroups.PostAsync(requestBody); Assert.NotNull(returnedCollectionPage); Assert.Equal(checkMemberGroupsCollectionPage, returnedCollectionPage.Value); @@ -178,7 +178,7 @@ public async System.Threading.Tasks.Task PostAsync_NonCollectionReturnType() adapter => adapter.SerializationWriterFactory.GetSerializationWriter(It.IsAny()) ).Returns(new JsonSerializationWriter()); - var permission = await graphServiceClient.Drives["driveId"].Items["id"].MicrosoftGraphCreateLink.PostAsync(requestBody); + var permission = await graphServiceClient.Drives["driveId"].Items["id"].CreateLink.PostAsync(requestBody); Assert.NotNull(permission); Assert.Equal(expectedPermission, permission); @@ -196,7 +196,7 @@ public async System.Threading.Tasks.Task PostAsync_NoReturnValue() adapter => adapter.SendNoContentAsync(It.IsAny(), It.IsAny>>(),It.IsAny() ) ).Callback(() => {}).Returns(Task.CompletedTask); - await graphServiceClient.Me.MailFolders["Drafts"].Messages["messageId"].MicrosoftGraphSend.PostAsync(); + await graphServiceClient.Me.MailFolders["Drafts"].Messages["messageId"].Send.PostAsync(); } } } diff --git a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/FunctionRequestTests.cs b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/FunctionRequestTests.cs index 0a30c3b07c8..cfbdada084e 100644 --- a/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/FunctionRequestTests.cs +++ b/tests/Microsoft.Graph.DotnetCore.Test/Requests/Generated/FunctionRequestTests.cs @@ -8,6 +8,7 @@ using Microsoft.Kiota.Abstractions; using Xunit; using Microsoft.Graph.DotnetCore.Test.Mocks; +using Microsoft.Graph.Beta.Models.ODataErrors; namespace Microsoft.Graph.DotnetCore.Test.Requests.Generated { @@ -20,9 +21,9 @@ public class FunctionRequestTests public void NoParameters() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); - var expectedRequestUrl = string.Format("{0}/drives/id/items/id/microsoft.graph.delta()", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var expectedRequestUrl = string.Format("{0}/drives/id/items/id/delta()", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); - var requestInformation = graphServiceClient.Drives["id"].Items["id"].MicrosoftGraphDelta.ToGetRequestInformation(); + var requestInformation = graphServiceClient.Drives["id"].Items["id"].Delta.ToGetRequestInformation(); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -37,10 +38,10 @@ public void OptionalParameter_ParameterSet() var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); var q = "value"; - var methodBaseUrl = string.Format("{0}/drives/id/items/id/microsoft.graph.search", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var methodBaseUrl = string.Format("{0}/drives/id/items/id/search", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); var expectedRequestUrl = string.Format("{0}(q='{1}')", methodBaseUrl, q); - var requestInformation = graphServiceClient.Drives["id"].Items["id"].MicrosoftGraphSearchWithQ(q).ToGetRequestInformation(); + var requestInformation = graphServiceClient.Drives["id"].Items["id"].SearchWithQ(q).ToGetRequestInformation(); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -56,10 +57,10 @@ public void RequiredAndOptionalParameters_AllParametersSet() var startDateTime = "now"; var endDateTime = "later"; - var methodBaseUrl = string.Format("{0}/me/microsoft.graph.reminderView", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var methodBaseUrl = string.Format("{0}/me/reminderView", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); var expectedRequestUrl = string.Format("{0}(StartDateTime='{2}',EndDateTime='{1}')", methodBaseUrl, startDateTime, endDateTime); - var requestInformation = graphServiceClient.Me.MicrosoftGraphReminderViewWithStartDateTimeWithEndDateTime(startDateTime, endDateTime).ToGetRequestInformation(); + var requestInformation = graphServiceClient.Me.ReminderViewWithStartDateTimeWithEndDateTime(startDateTime, endDateTime).ToGetRequestInformation(); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -75,11 +76,10 @@ public void RequiredAndOptionalParameters_RequiredParameterNull() var graphServiceClient = new GraphServiceClient(mockRequestAdapter.Object); try { - Assert.Throws(() => graphServiceClient.Me.MicrosoftGraphReminderViewWithStartDateTimeWithEndDateTime("","")); + Assert.Throws(() => graphServiceClient.Me.ReminderViewWithStartDateTimeWithEndDateTime("","")); } - catch (ServiceException serviceException) + catch (ODataError serviceException) { - Assert.True(serviceException.IsMatch(GraphErrorCode.InvalidRequest.ToString())); Assert.Equal( "startDateTime is a required parameter for this method request.", serviceException.Error.Message); @@ -95,9 +95,9 @@ public void RequiredAndOptionalParameters_RequiredParameterNull() public void Top() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); - var expectedRequestUrl = string.Format("{0}/me/microsoft.graph.reminderView(StartDateTime='now',EndDateTime='then')?%24top=1", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var expectedRequestUrl = string.Format("{0}/me/reminderView(StartDateTime='now',EndDateTime='then')?%24top=1", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); - var requestInformation = graphServiceClient.Me.MicrosoftGraphReminderViewWithStartDateTimeWithEndDateTime("then","now").ToGetRequestInformation( requestConfiguration =>requestConfiguration.QueryParameters.Top =1 ); + var requestInformation = graphServiceClient.Me.ReminderViewWithStartDateTimeWithEndDateTime("then","now").ToGetRequestInformation( requestConfiguration =>requestConfiguration.QueryParameters.Top =1 ); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI); @@ -110,9 +110,9 @@ public void Top() public void Skip() { var graphServiceClient = new GraphServiceClient(new MockAuthenticationProvider().Object); - var expectedRequestUrl = string.Format("{0}/me/microsoft.graph.reminderView(StartDateTime='now',EndDateTime='then')?%24skip=1", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); + var expectedRequestUrl = string.Format("{0}/me/reminderView(StartDateTime='now',EndDateTime='then')?%24skip=1", string.Format(Constants.Url.GraphBaseUrlFormatString, "beta")); - var requestInformation = graphServiceClient.Me.MicrosoftGraphReminderViewWithStartDateTimeWithEndDateTime("then","now").ToGetRequestInformation( requestConfiguration =>requestConfiguration.QueryParameters.Skip =1 ); + var requestInformation = graphServiceClient.Me.ReminderViewWithStartDateTimeWithEndDateTime("then","now").ToGetRequestInformation( requestConfiguration =>requestConfiguration.QueryParameters.Skip =1 ); Assert.NotNull(requestInformation); Assert.Equal(new Uri(expectedRequestUrl), requestInformation.URI);