Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples update #61

Merged
merged 7 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions samples/Graph.Community.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>68071ad2-6ee0-41d1-ad86-2635c69bfadf</UserSecretsId>
<Configurations>Debug;Prerelease;LocalDev</Configurations>
<LangVersion>latest</LangVersion>
Expand All @@ -20,13 +20,13 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.2" />
<PackageReference Include="microsoft.extensions.caching.memory" Version="3.1.18" />
<PackageReference Include="microsoft.extensions.configuration" Version="3.1.18" />
<PackageReference Include="microsoft.extensions.configuration.binder" Version="3.1.18" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.18" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.18" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.18" />
<PackageReference Include="microsoft.extensions.caching.memory" Version="7.0.0" />
<PackageReference Include="microsoft.extensions.configuration" Version="7.0.0" />
<PackageReference Include="microsoft.extensions.configuration.binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions test/Graph.Community.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<None Remove="Mocks\GetSiteResponse.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Mocks\ApplySiteDesignResponse.json" />
<EmbeddedResource Include="Mocks\CreateSiteDesignResponse.json" />
Expand All @@ -25,6 +29,7 @@
<EmbeddedResource Include="Mocks\GetSitePageResponse.json" />
<EmbeddedResource Include="Mocks\GetSitePagesResponse.json" />
<EmbeddedResource Include="Mocks\GetSitePageVersionsResponse.json" />
<EmbeddedResource Include="Mocks\GetSiteResponse.json" />
<EmbeddedResource Include="Mocks\GetSiteScriptMetadataResponse.json" />
<EmbeddedResource Include="Mocks\GetSiteScriptsResponse.json" />
<EmbeddedResource Include="Mocks\GetSiteUserResponse.json" />
Expand Down
55 changes: 55 additions & 0 deletions test/Mocks/GetSiteResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"@odata.context": "https://mock.sharepoint.com/sites/mockSite/_api/$metadata#site",
"@odata.type": "#SP.Site",
"@odata.id": "https://mock.sharepoint.com/sites/mockSite/_api/site",
"@odata.editLink": "site",
"AllowCreateDeclarativeWorkflow": true,
"AllowDesigner": true,
"AllowMasterPageEditing": false,
"AllowRevertFromTemplate": false,
"AllowSaveDeclarativeWorkflowAsTemplate": true,
"AllowSavePublishDeclarativeWorkflow": true,
"AllowSelfServiceUpgrade": true,
"AllowSelfServiceUpgradeEvaluation": true,
"AuditLogTrimmingRetention": 90,
"ChannelGroupId": "00000000-0000-0000-0000-000000000000",
"Classification": "Internal Only",
"CompatibilityLevel": 15,
"CurrentChangeToken": {
"StringValue": "1;1;8df4bb1e-2a3d-4996-a5c9-1e6455707397;638331437218930000;476750435"
},
"DisableAppViews": false,
"DisableCompanyWideSharingLinks": false,
"DisableFlows": false,
"ExternalSharingTipsEnabled": false,
"GeoLocation": "GBR",
"GroupId": "00000000-0000-0000-0000-000000000000",
"HubSiteId": "354401ad-7245-45c6-afae-8ff465b66807",
"Id": "8df4bb1e-2a3d-4996-a5c9-1e6455707397",
"SensitivityLabelId": "76c9f618-8103-49b1-9cc5-fa6cea342fb2",
"SensitivityLabel": "00000000-0000-0000-0000-000000000000",
"IsHubSite": false,
"LockIssue": null,
"MaxItemsPerThrottledOperation": 5000,
"MediaTranscriptionDisabled": false,
"NeedsB2BUpgrade": false,
"ResourcePath": {
"DecodedUrl": "https://mock.sharepoint.com/sites/mockSite"
},
"PrimaryUri": "https://mock.sharepoint.com/sites/mockSite",
"ReadOnly": false,
"RequiredDesignerVersion": "15.0.0.0",
"SandboxedCodeActivationCapability": 2,
"ServerRelativeUrl": "/sites/mockSite",
"ShareByEmailEnabled": false,
"ShareByLinkEnabled": false,
"ShowUrlStructure": false,
"TrimAuditLog": true,
"UIVersionConfigurationEnabled": false,
"UpgradeReminderDate": "1899-12-30T00:00:00-08:00",
"UpgradeScheduled": false,
"UpgradeScheduledDate": "1753-01-01T00:00:00-08:00",
"Upgrading": false,
"Url": "https://mock.sharepoint.com/sites/mockSite",
"WriteLocked": false
}
2 changes: 1 addition & 1 deletion test/Mocks/GetWebResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"TimeZone@odata.navigationLinkUrl": "Web/RegionalSettings/TimeZone",
"TimeZone": {
"odata.type": "SP.TimeZone",
"odata.id": "https://devaddin365.sharepoint.com/sites/Eventtester/_api/Web/RegionalSettings/TimeZone",
"odata.id": "https://mock.sharepoint.com/sites/mockSite/_api/Web/RegionalSettings/TimeZone",
"odata.editLink": "Web/RegionalSettings/TimeZone",
"Description": "(UTC-08:00) Pacific Time (US and Canada)",
"Id": 13,
Expand Down
31 changes: 31 additions & 0 deletions test/SiteRequestTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Moq;
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -39,6 +40,36 @@ public void GeneratesCorrectRequestHeaders()
Assert.Equal(SharePointAPIRequestConstants.Headers.ODataVersionHeaderValue, string.Join(',', request.Headers.GetValues(SharePointAPIRequestConstants.Headers.ODataVersionHeaderName)));
}

[Fact]
public async void Get_ReturnsCorrectResponse()
{
// ARRANGE
var responseContent = ResourceManager.GetHttpResponseContent("GetSiteResponse.json");
var responseMessage = new HttpResponseMessage()
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent(responseContent),
};

using (responseMessage)
using (TestGraphServiceClient gsc = TestGraphServiceClient.Create(responseMessage))
{
// ACT
var actual = await gsc.GraphServiceClient
.SharePointAPI(mockWebUrl)
.Site
.Request()
.GetAsync();

// ASSERT
Assert.Equal("Internal Only", actual.Classification);
Assert.Equal("00000000-0000-0000-0000-000000000000", actual.GroupId);
Assert.Equal("354401ad-7245-45c6-afae-8ff465b66807", actual.HubSiteId);
Assert.False(actual.IsHubSite);
Assert.Equal("/sites/mockSite", actual.ServerRelativeUrl);
}
}

[Fact]
public async Task Get_GeneratesCorrectRequest()
{
Expand Down
Loading