Skip to content

Commit 1f20efb

Browse files
Updated WCT to 7.1.0rc (#150)
1 parent 3ca6264 commit 1f20efb

File tree

10 files changed

+79
-23
lines changed

10 files changed

+79
-23
lines changed

CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
</PropertyGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
27-
<PackageReference Include="Microsoft.Graph" Version="4.2.0" />
28-
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Input" Version="7.0.2" />
26+
<PackageReference Include="Microsoft.Graph" Version="4.3.0" />
27+
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Input" Version="7.1.0-rc1" />
2928
</ItemGroup>
3029

3130
<ItemGroup>

CommunityToolkit.Graph/CommunityToolkit.Graph.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.Graph" Version="4.2.0" />
24-
<PackageReference Include="Microsoft.Toolkit" Version="7.1.0-preview1" />
23+
<PackageReference Include="Microsoft.Graph" Version="4.3.0" />
24+
<PackageReference Include="Microsoft.Toolkit" Version="7.1.0-rc1" />
2525
</ItemGroup>
2626

2727
<ItemGroup>

CommunityToolkit.Graph/Extensions/GraphExtensions.OneDrive.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public static partial class GraphExtensions
2020
/// <summary>
2121
/// Updates or create a new file on the remote with the provided content.
2222
/// </summary>
23+
/// <param name="graph">Instance of the <see cref="GraphServiceClient"/>.</param>
24+
/// <param name="userId">The id of the target Graph user.</param>
25+
/// <param name="itemPath">The path of the target item.</param>
26+
/// <param name="fileContents">The contents to put in the file.</param>
27+
/// <param name="serializer">A serializer for converting stored values.</param>
2328
/// <typeparam name="T">The type of object to save.</typeparam>
2429
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
2530
public static async Task<DriveItem> SetFileAsync<T>(this GraphServiceClient graph, string userId, string itemPath, T fileContents, IObjectSerializer serializer)
@@ -33,6 +38,10 @@ public static async Task<DriveItem> SetFileAsync<T>(this GraphServiceClient grap
3338
/// <summary>
3439
/// Get a file from the remote.
3540
/// </summary>
41+
/// <param name="graph">Instance of the <see cref="GraphServiceClient"/>.</param>
42+
/// <param name="userId">The id of the target Graph user.</param>
43+
/// <param name="itemPath">The path of the target item.</param>
44+
/// <param name="serializer">A serializer for converting stored values.</param>
3645
/// <typeparam name="T">The type of object to return.</typeparam>
3746
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
3847
public static async Task<T> GetFileAsync<T>(this GraphServiceClient graph, string userId, string itemPath, IObjectSerializer serializer)
@@ -47,12 +56,33 @@ public static async Task<T> GetFileAsync<T>(this GraphServiceClient graph, strin
4756
/// <summary>
4857
/// Delete the file from the remote.
4958
/// </summary>
59+
/// <param name="graph">Instance of the <see cref="GraphServiceClient"/>.</param>
60+
/// <param name="userId">The id of the target Graph user.</param>
61+
/// <param name="itemPath">The path of the target item.</param>
5062
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
5163
public static async Task DeleteItemAsync(this GraphServiceClient graph, string userId, string itemPath)
5264
{
5365
await graph.Users[userId].Drive.Special.AppRoot.ItemWithPath(itemPath).Request().DeleteAsync();
5466
}
5567

68+
/// <summary>
69+
/// Rename an item.
70+
/// </summary>
71+
/// <param name="graph">Instance of the <see cref="GraphServiceClient"/>.</param>
72+
/// <param name="userId">The id of the target Graph user.</param>
73+
/// <param name="itemPath">The path of the target item.</param>
74+
/// <param name="newName">The new name for the item.</param>
75+
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
76+
public static async Task RenameItemAsync(this GraphServiceClient graph, string userId, string itemPath, string newName)
77+
{
78+
var driveItem = new DriveItem
79+
{
80+
Name = newName,
81+
};
82+
83+
await graph.Users[userId].Drive.Special.AppRoot.ItemWithPath(itemPath).Request().UpdateAsync(driveItem);
84+
}
85+
5686
/// <summary>
5787
/// Ensure a folder exists by name.
5888
/// </summary>

CommunityToolkit.Graph/Helpers/RoamingSettings/OneDriveStorageHelper.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,35 @@ public Task CreateFolderAsync(string folderName, string folderPath)
9595
}
9696

9797
/// <inheritdoc />
98-
public Task DeleteItemAsync(string itemPath)
98+
public async Task<bool> TryDeleteItemAsync(string itemPath)
9999
{
100-
var graph = GetGraphClient();
101-
return graph.DeleteItemAsync(UserId, itemPath);
100+
try
101+
{
102+
var graph = GetGraphClient();
103+
await graph.DeleteItemAsync(UserId, itemPath);
104+
105+
return true;
106+
}
107+
catch
108+
{
109+
return false;
110+
}
111+
}
112+
113+
/// <inheritdoc />
114+
public async Task<bool> TryRenameItemAsync(string itemPath, string newName)
115+
{
116+
try
117+
{
118+
var graph = GetGraphClient();
119+
await graph.RenameItemAsync(UserId, itemPath, newName);
120+
121+
return true;
122+
}
123+
catch
124+
{
125+
return false;
126+
}
102127
}
103128

104129
private static GraphServiceClient GetGraphClient()

SampleTest/SampleTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
</ItemGroup>
210210
<ItemGroup>
211211
<PackageReference Include="Microsoft.Graph">
212-
<Version>4.2.0</Version>
212+
<Version>4.3.0</Version>
213213
</PackageReference>
214214
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
215215
<Version>6.2.12</Version>

UnitTests/UnitTests.UWP/Providers/Test_MockProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using CommunityToolkit.Authentication;
6-
using Microsoft.VisualStudio.TestTools.UnitTesting;
75
using System;
86
using System.Net.Http;
97
using System.Threading.Tasks;
8+
using CommunityToolkit.Authentication;
9+
using Microsoft.VisualStudio.TestTools.UnitTesting;
1010

1111
namespace UnitTests.UWP.Authentication
1212
{

UnitTests/UnitTests.UWP/Providers/Test_WindowsProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.Threading.Tasks;
57
using CommunityToolkit.Authentication;
68
using Microsoft.Toolkit.Uwp;
79
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
using System;
9-
using System.Threading.Tasks;
1010

1111
namespace UnitTests.UWP.Authentication
1212
{

UnitTests/UnitTests.UWP/RoamingSettings/Test_OneDriveDataStore.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.Linq;
7+
using System.Threading.Tasks;
58
using CommunityToolkit.Authentication;
69
using CommunityToolkit.Graph.Helpers.RoamingSettings;
710
using Microsoft.Toolkit.Helpers;
811
using Microsoft.Toolkit.Uwp;
912
using Microsoft.Toolkit.Uwp.Helpers;
1013
using Microsoft.VisualStudio.TestTools.UnitTesting;
11-
using System;
12-
using System.Linq;
13-
using System.Threading.Tasks;
1414

1515
namespace UnitTests.UWP.Helpers
1616
{
@@ -77,7 +77,8 @@ async void test()
7777
Assert.AreEqual(fileContents2, readContents2);
7878

7979
// Delete a file
80-
await storageHelper.DeleteItemAsync(filePath);
80+
var itemDeleted = await storageHelper.TryDeleteItemAsync(filePath);
81+
Assert.IsTrue(itemDeleted);
8182

8283
tcs.SetResult(true);
8384
}
@@ -111,7 +112,7 @@ async void test()
111112

112113
// Create a folder
113114
await storageHelper.CreateFolderAsync(folderName);
114-
115+
115116
// Create a subfolder
116117
await storageHelper.CreateFolderAsync(subfolderName, folderName);
117118

@@ -132,7 +133,8 @@ async void test()
132133
Assert.AreEqual(DirectoryItemType.File, folderItemsList[1].ItemType);
133134

134135
// Delete a folder
135-
await storageHelper.DeleteItemAsync(folderName);
136+
var itemDeleted = await storageHelper.TryDeleteItemAsync(folderName);
137+
Assert.IsTrue(itemDeleted);
136138

137139
tcs.SetResult(true);
138140
}

UnitTests/UnitTests.UWP/RoamingSettings/Test_UserExtensionDataStore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.Threading.Tasks;
57
using CommunityToolkit.Authentication;
68
using CommunityToolkit.Graph.Helpers.RoamingSettings;
79
using Microsoft.Toolkit.Extensions;
810
using Microsoft.Toolkit.Helpers;
911
using Microsoft.Toolkit.Uwp;
1012
using Microsoft.VisualStudio.TestTools.UnitTesting;
11-
using System;
12-
using System.Threading.Tasks;
1313

1414
namespace UnitTests.UWP.Helpers
1515
{

UnitTests/UnitTests.UWP/VisualUITestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.Threading.Tasks;
57
using Microsoft.Toolkit.Uwp;
68
using Microsoft.Toolkit.Uwp.UI.Helpers;
79
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
using System;
9-
using System.Threading.Tasks;
1010
using Windows.UI.Xaml;
1111

1212
namespace UnitTests.UWP

0 commit comments

Comments
 (0)