-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'shem/php_snipet_imports' of github.com:microsoftgraph/m…
…icrosoft-graph-devx-api into shem/php_snipet_imports
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -544,6 +544,69 @@ public async Task GenerateForComplexMapValues() | |
Assert.Contains("'@odata.type' => '#microsoft.graph.identity',", result); | ||
Assert.Contains("'id' => '+12345678901',", result); | ||
} | ||
|
||
[Fact] | ||
public async Task GeneratesRequestBuilderImports() | ||
{ | ||
using var requestPayload = new HttpRequestMessage(HttpMethod.Get, $"{ServiceRootUrl}/me/calendar/events?$filter=startsWith(subject,'All')"); | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); | ||
var result = _generator.GenerateCodeSnippet(snippetModel); | ||
Assert.Contains("use Microsoft\\Graph\\Graph;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Users\\Item\\Calendar\\Events", result); | ||
} | ||
|
||
|
||
[Fact] | ||
public async Task GenerateModelImports(){ | ||
var bodyContent = @"{ | ||
""displayName"": ""New display name"" | ||
}"; | ||
using var requestPayload = new HttpRequestMessage(HttpMethod.Patch, $"{ServiceRootUrl}/applications/{{id}}") | ||
{ | ||
Content = new StringContent(bodyContent, Encoding.UTF8, "application/json") | ||
}; | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); | ||
var result = _generator.GenerateCodeSnippet(snippetModel); | ||
Assert.Contains("use Microsoft\\Graph\\Graph;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models;", result); | ||
|
||
} | ||
|
||
[Fact] | ||
public async Task GenerateComplexModelImports(){ | ||
var bodyContent = @"{ | ||
""subject"": ""Annual review"", | ||
""body"": { | ||
""contentType"": ""HTML"", | ||
""content"": ""You should be proud!"" | ||
}, | ||
""toRecipients"": [ | ||
{ | ||
""emailAddress"": { | ||
""address"": ""[email protected]"" | ||
} | ||
} | ||
], | ||
""extensions"": [ | ||
{ | ||
""@odata.type"": ""microsoft.graph.openTypeExtension"", | ||
""extensionName"": ""Com.Contoso.Referral"", | ||
""companyName"": ""Wingtip Toys"", | ||
""expirationDate"": ""2015-12-30T11:00:00.000Z"", | ||
""dealValue"": 10000 | ||
} | ||
] | ||
}"; | ||
using var requestPayload = new HttpRequestMessage(HttpMethod.Post, $"{ServiceRootUrl}/me/messages/") | ||
{ | ||
Content = new StringContent(bodyContent, Encoding.UTF8, "application/json") | ||
}; | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); | ||
var result = _generator.GenerateCodeSnippet(snippetModel); | ||
Assert.Contains("use Microsoft\\Graph\\Graph;", result); | ||
Assert.Contains("use Microsoft\\Graph\\Generated\\Models;", result); | ||
|
||
} | ||
|
||
[Fact] | ||
public async Task GenerateForMoreComplexMapping() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters