From df06bac923e75e03bcdbfc98a8b2cd836c884d1a Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Mon, 24 Jul 2023 15:44:49 +0300 Subject: [PATCH] Modified tests to accomodate notice message --- .../GraphCliGeneratorTests.cs | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/CodeSnippetsReflection.OpenAPI.Test/GraphCliGeneratorTests.cs b/CodeSnippetsReflection.OpenAPI.Test/GraphCliGeneratorTests.cs index ace22bd08..57875236e 100644 --- a/CodeSnippetsReflection.OpenAPI.Test/GraphCliGeneratorTests.cs +++ b/CodeSnippetsReflection.OpenAPI.Test/GraphCliGeneratorTests.cs @@ -14,7 +14,7 @@ namespace CodeSnippetsReflection.OpenAPI.LanguageGenerators; public class GraphCliGeneratorTests : OpenApiSnippetGeneratorTestBase { private readonly GraphCliGenerator _generator = new(); - + private static string notice = "// THE CLI SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY"; public static IEnumerable GetSnippetData() { return new[] { @@ -39,7 +39,7 @@ public async Task GeneratesSnippetsForCommands(HttpMethod method, string url, st var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal(expectedCommand, result); + Assert.Equal(notice + Environment.NewLine + expectedCommand, result); } [Fact] @@ -55,7 +55,7 @@ public async Task GeneratesSnippetsForDeepSubCommand() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users todo lists tasks attachments get --user-id {user-id} --todo-task-list-id {todoTaskList-id} --todo-task-id {todoTask-id} --attachment-base-id {attachmentBase-id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc users todo lists tasks attachments get --user-id {user-id} --todo-task-list-id {todoTaskList-id} --todo-task-id {todoTask-id} --attachment-base-id {attachmentBase-id}", result); } [Theory] @@ -78,7 +78,7 @@ public void GeneratesSnippetsForConflictingIndexerNavSubCommand(string url, stri var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal(expectedCommand, result); + Assert.Equal(notice + Environment.NewLine + expectedCommand, result); } // Powershell metadata doesn't have /$count endpoints @@ -98,7 +98,7 @@ public void GeneratesSnippetsForCountCommand() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc tests count get", result); + Assert.Equal(notice + Environment.NewLine + "mgc tests count get", result); } [Fact] @@ -131,7 +131,7 @@ public async Task GeneratesSnippetsForRefCommand() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users manager ref get --user-id {user-id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc users manager ref get --user-id {user-id}", result); } [Fact] @@ -147,7 +147,7 @@ public async Task GeneratesSnippetsForContentCommand() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users photo content get --user-id {user-id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc users photo content get --user-id {user-id}", result); } [Fact] @@ -162,7 +162,7 @@ public async Task GeneratesSnippetsForGetListCommand() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users list", result); + Assert.Equal(notice + Environment.NewLine + "mgc users list", result); } [Theory] @@ -187,7 +187,7 @@ public void GeneratesSnippetsForCommandWithConflictingParameterName(string query // Then // TODO: What should happen to the query parameter? - Assert.Equal($"mgc tests results get {commandSuffix}", result); + Assert.Equal(notice + Environment.NewLine + $"mgc tests results get {commandSuffix}", result); } [Fact] @@ -209,7 +209,7 @@ public void GeneratesSnippetsForCommandWithConflictingParameterNameAndNoLocation // Then // TODO: What should happen to the query parameter? - Assert.Equal("mgc tests results get --id {id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc tests results get --id {id}", result); } [Fact] @@ -229,7 +229,7 @@ public void GeneratesSnippetsForCommandWithConflictingPathAndCookieParameterName var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc tests results get --id {id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc tests results get --id {id}", result); } [Fact] @@ -250,7 +250,7 @@ public void GeneratesSnippetsForCommandWithConflictingPathAndHeaderParameterName var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc tests results get --id {id} --id-header test-header", result); + Assert.Equal(notice + Environment.NewLine + "mgc tests results get --id {id} --id-header test-header", result); } [Theory] @@ -267,7 +267,7 @@ public async Task GeneratesSnippetsForCommandWithODataParameters(string queryStr var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal($"mgc users list{commandOptions}", result); + Assert.Equal(notice + Environment.NewLine + $"mgc users list{commandOptions}", result); } [Fact] @@ -287,7 +287,7 @@ public void GeneratesSnippetsForCommandWithEmptyParameterNames() // Then // TODO: What should happen to the query parameter? - Assert.Equal("mgc tests get", result); + Assert.Equal(notice + Environment.NewLine + "mgc tests get", result); } [Fact] @@ -307,7 +307,7 @@ public void GeneratesSnippetsForCommandWithQueryParameters() // Then // TODO: What should happen to the query parameter? - Assert.Equal("mgc tests get --id 10", result); + Assert.Equal(notice + Environment.NewLine + "mgc tests get --id 10", result); } [Theory] @@ -329,7 +329,7 @@ public async Task GeneratesSnippetsForCreateInListCommandWithBody(string content var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal(expectedCommand, result); + Assert.Equal(notice + Environment.NewLine + expectedCommand, result); } [Theory] @@ -365,7 +365,7 @@ public async Task GeneratesSnippetsForCreateInListCommandWithInvalidContent(stri var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users create", result); + Assert.Equal(notice + Environment.NewLine + "mgc users create", result); } [Fact] @@ -406,7 +406,7 @@ public async Task GeneratesEscapedSnippetsForMultilineCommand() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users create --body '{\\\n \"name\": \"test\"\\\n}'", result); + Assert.Equal(notice + Environment.NewLine + "mgc users create --body '{\\\n \"name\": \"test\"\\\n}'", result); } [Fact] @@ -421,7 +421,7 @@ public async Task GeneratesSnippetsContainingOverLoadedBoundFunctionsWithDatePar var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc reports get-yammer-device-usage-user-detail-with-date get --date {date-id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc reports get-yammer-device-usage-user-detail-with-date get --date {date-id}", result); } [Fact] @@ -436,7 +436,7 @@ public async Task GeneratesSnippetsContainingOverLoadedBoundFunctionsWithDatePar var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc reports get-yammer-device-usage-user-detail-with-date get --date '{date-id}'", result); + Assert.Equal(notice + Environment.NewLine + "mgc reports get-yammer-device-usage-user-detail-with-date get --date '{date-id}'", result); } [Fact] @@ -451,7 +451,7 @@ public async Task GeneratesSnippetsContainingOverLoadedBoundFunctionsWithNonDate var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc drives items delta-with-token get --token '{token-id}' --drive-id {drive-id} --drive-item-id {driveItem-id}", result); + Assert.Equal(notice + Environment.NewLine + "mgc drives items delta-with-token get --token '{token-id}' --drive-id {drive-id} --drive-item-id {driveItem-id}", result); } [Fact] @@ -466,7 +466,7 @@ public async Task GeneratesSnippetsContainingUnBoundedFunctions() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc identity identity-providers available-provider-types get", result); + Assert.Equal(notice + Environment.NewLine + "mgc identity identity-providers available-provider-types get", result); } [Fact] @@ -481,7 +481,7 @@ public async Task GeneratesSnippetsWithSlashMeEndpoints() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users calendar events list --user-id {user-id} --filter \"startsWith(subject,'All')\"", result); + Assert.Equal(notice + Environment.NewLine + "mgc users calendar events list --user-id {user-id} --filter \"startsWith(subject,'All')\"", result); } [Fact] public async Task GeneratesSnippetsWithExpandQueryOptions() @@ -495,7 +495,7 @@ public async Task GeneratesSnippetsWithExpandQueryOptions() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc users messages get --user-id {user-id} --message-id {message-id} --expand \"singleValueExtendedProperties(`$filter=id eq 'XXXX')\"", result); + Assert.Equal(notice + Environment.NewLine + "mgc users messages get --user-id {user-id} --message-id {message-id} --expand \"singleValueExtendedProperties(`$filter=id eq 'XXXX')\"", result); } [Fact] public async Task GeneratesSnippetsWithFilterQueryOptions() @@ -509,7 +509,7 @@ public async Task GeneratesSnippetsWithFilterQueryOptions() var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc identity-governance access-reviews definitions list --filter \"contains(scope/microsoft.graph.accessReviewQueryScope/query, './members')\"", result); + Assert.Equal(notice + Environment.NewLine + "mgc identity-governance access-reviews definitions list --filter \"contains(scope/microsoft.graph.accessReviewQueryScope/query, './members')\"", result); } [Fact] @@ -524,6 +524,6 @@ public async Task GeneratesSnippetsForHttpSnippetsWithUrlEncodedValuesForSystemQ var result = _generator.GenerateCodeSnippet(snippetModel); // Then - Assert.Equal("mgc teams members list --team-id {team-id} --filter \"(microsoft.graph.aadUserConversationMember/displayName eq 'Harry Johnson' or microsoft.graph.aadUserConversationMember/email eq 'admin@M365x987948.OnMicrosoft.com')\"", result); + Assert.Equal(notice + Environment.NewLine + "mgc teams members list --team-id {team-id} --filter \"(microsoft.graph.aadUserConversationMember/displayName eq 'Harry Johnson' or microsoft.graph.aadUserConversationMember/email eq 'admin@M365x987948.OnMicrosoft.com')\"", result); } }