You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/3-testing-with-copilot.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
## Overview
5
5
6
6
**Goal:**
7
-
By the end of this session, you will learn how you can use GitHub Copilot Copilot Edits (preview) and other features to enhance test projects by creating new unit and integration test cases.
7
+
By the end of this session, you will learn how you can use GitHub Copilot Edits (preview) and other features to enhance test projects by creating new unit and integration test cases.
8
8
You will create unit tests for the BasketItem class in the Basket.UnitTests, as well as cover additional scenario in Catalog.FunctionalTests projects.
9
9
10
10
By the end of this lab, you will have enhanced two test projects in the solution and gained practical experience with Copilot Edits (preview) and other features.
@@ -81,7 +81,7 @@ In this step, you will create a new unit tests class with some simple test cases
81
81
2. Open Copilot Edits by pressing Ctrl-Shift-I.
82
82
3. Verify **BasketItem.cs** file is included in the Working Set, and click + add **Basket.UnitTests.csproj** file.
83
83
4. Ensure model **o1-mini (Preview)** is selected (right corner of the Copilot Edits command bar down below).
84
-
5. Enter following request "Generate unit tests for BasketItem methods and save in the Basket.UnitTests.csproj. Include edge cases." and press Enter.
84
+
5. Enter following request `Generate unit tests for BasketItem methods and save in the Basket.UnitTests.csproj. Include edge cases.` and press Enter.
85
85
In a few moments, unit tests code will be generated in a new file **BasketItemTests.cs** that will show as unsaved file in the editor..
86
86
6. Observe the generated code.
87
87
7. (Optional) If you find that further improvements can be made, you can ask Copilot Edits and iterate prompting until desired qualities are met.
@@ -116,7 +116,7 @@ In this step, you will work with GitHub Copilot to add a test case to the existi
116
116
3. Verify **CatalogApiTests.cs** file is included in the Working Set
117
117
4. Ensure model **o1-mini (Preview)** is selected (right corner of the Copilot Edits command bar down below).
118
118
5. In the **CatalogApiTests.cs** file, scroll down and select test case *GetCatalogItemWithId()*.
119
-
6. In Copilot Edits prompt field, enter "Consider selected test case. It expects record with the given id. Can you make a test case where no item is returned with the given id?" and press Enter.
119
+
6. In Copilot Edits prompt field, enter `Consider selected test case. It expects record with the given id. Can you make a test case where no item is returned with the given id?` and press Enter.
120
120
In a few moments, the requested tests case will be generated in **CatalogApiTests.cs**.
121
121
7. Observe the generated code. The changes are highlighted.
122
122
8. (Optional) You may further ask about reasoning why no items will be returned, which can lead into discussion on where 400 or 404 is more appropriate!
Copy file name to clipboardexpand all lines: docs/4-creating-documentation-with-copilot.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -89,11 +89,11 @@ In this step, we will use Copilot Edits to generate API documentation for `api/o
89
89
Generate a readme markdown file for the project by entering the following prompt:
90
90
91
91
```plaintext
92
-
Generaete API documentation for api/orders resource using OpenAPI Specification in YAML format and save it in Ordering.API.YAML file
92
+
Generate API documentation for api/orders resource using OpenAPI Specification in YAML format and save it in Ordering.API.YAML file
93
93
```
94
94
95
95
4. GitHub Copilot confirms the plan and creates requested documentation to the Ordering.API.md file.
96
-
5. Observe the content of the file. You can open the file preview by pressing `Ctrl-Shift-V`.
96
+
5. Observe the content of the file.
97
97
6. Sometimes copilot generates more methods and other times it might not generate all the methods for the API. Add the following prompt to explicitly specify the number of methods in the API:
98
98
99
99
```plaintext
@@ -105,10 +105,10 @@ Generate a readme markdown file for the project by entering the following prompt
105
105
9. Now lets generate the same content in JSON format. We can do so by by specifying the format and the file name as follows:
106
106
107
107
```plaintext
108
-
Generaete API documentation for the 7 methods in api/orders resource using OpenAPI Specification in JSON format and save it in Ordering.API.JSON file
108
+
Generate API documentation for the 7 methods in api/orders resource using OpenAPI Specification in JSON format and save it in Ordering.API.JSON file
109
109
```
110
110
111
-
10. Observe the content of the file. You can open the file preview by pressing `Ctrl-Shift-V`.
Copy file name to clipboardexpand all lines: docs/5-devops-with-copilot.md
+10-9
Original file line number
Diff line number
Diff line change
@@ -39,16 +39,17 @@ To successfully complete this lab, ensure you have the following:
39
39
In this step we will generate a build pipeline for the `OrdersApi` using GitHub Actions.
40
40
41
41
1. In Visual Studio Code, navigate to the `samples/eshop/src/Ordering.API` folder.
42
-
2. Open the Copilot Edits pane in Visual Studio Code by clicking the Copilot icon in the sidebar or using the command palette (`Ctrl+Shift+I`). In the chat settings, Lets select `Claude 3.5 Sonnet (Preview)` model for API documentation.
42
+
2. Open the Copilot Edits pane in Visual Studio Code by clicking the Copilot icon in the sidebar or using the command palette (`Ctrl+Shift+I`). In the chat settings, let's select `Claude 3.5 Sonnet (Preview)` model for API documentation.
43
43
3. Open `Orders.Api.cs` and `Ordering.API.csproj` files.
44
-
4. Next we will develop a GitHub action that will create a YAML file to generates a build for Orders API. Enter the following prompt in the chat:
44
+
4. Next we will develop a GitHub action that will create a YAML file to generate a build for Orders API. Enter the following prompt in the chat:
45
45
46
46
```plaintext
47
47
add a github action to generate build for Ordering.API and name it `ordering-api-build.yml` and place it under eshop/.github/workflows folder
48
48
```
49
49
50
-
5. Observe the content of the file. You can open the file preview by pressing `Ctrl-Shift-V`.
51
-
6. This looks good but we would like to parameterize some of the elements in this pipeline (for example: the artifact location). Use the following prompt to parameterize the GitHub Action:
50
+
5. Observe the content of the file.
51
+
6. This looks good but we would like to parameterize some of the elements in this pipeline (for example: the artifact location).
52
+
Use the following prompt to parameterize the GitHub Action:
52
53
53
54
``` plaintext
54
55
parameterize the workflow so it takes inputs such as the branch name to build, the build configuration (e.g., Debug or Release). Use on: workflow_dispatch to accept these inputs and include steps for checking out the code, running the build using a script, and uploading the build artifacts. The workflow should use environment variables derived from the inputs to control the build process
@@ -107,8 +108,8 @@ In the previous steps, we've developed workflows to create a build and deploy th
107
108
Create a dockerfile for Ordering.API.csproj and add docker support for the project. Save the dockerfile in the project folder
108
109
```
109
110
110
-
5. Confirm that co-pilot created a Dockerfile, a .dockerignore file.
111
-
6. Next create a build Image pipeline that creates an image using the Dockerfile and publishes the image to Azure container Registry. Check to make sure the project file and the docker files are still in the Co-pilot edits' working set. Enter the following in Co-pilot edits chat:
111
+
5. Confirm that Copilot created a Dockerfile, a .dockerignore file.
112
+
6. Next create a build Image pipeline that creates an image using the Dockerfile and publishes the image to Azure Container Registry. Check to make sure the project file and the docker files are still in the Copilot Edits' working set. Enter the following in Copilot Edits' chat:
112
113
113
114
```plaintext
114
115
generate a github action workflow to build the docker image for Ordering.API using the Dockerfile and publish the image to Azure container registry. Parameterize the workflow file for all azure inputs and build configurations. save it in a file named ordering-api-build-image.yml under eshop/.github/workflows folder
@@ -165,11 +166,11 @@ In the previous steps, we've worked directly with GitHub Copilot to create a bui
165
166
166
167
1. In Visual Studio Code, navigate to the `samples/eshop` folder.
167
168
2. Open the Copilot Chat using the command shortcut (`Ctrl+Alt+I`). Keep the `Claude 3.5 Sonnet (Preview)` model selected.
168
-
3. In Chat view, type "@azure how can you help with Azure?" or similar prompt and press Enter.
169
+
3. In Chat view, type `@azure how can you help with Azure?` or similar prompt and press Enter.
169
170
GitHub will response with a sample list of the services it can help with.
170
-
4. Next, type "@azure which subscriptions I can use?" and press Enter.
171
+
4. Next, type `@azure which subscriptions I can use?` and press Enter.
171
172
The assistant will reply with available subscriptions, if any.
172
-
5. Next, type "@azure can you create the files I need to deploy this solution?" and press Enter.
173
+
5. Next, type `@azure can you create the files I need to deploy this solution?` and press Enter.
173
174
The Assistant will suggest requested files, such as .bicep file for AKS cluster and manifests for deployments and services, as well as the steps to deploy them.
Copy file name to clipboardexpand all lines: docs/6-best-practices-with-copilot.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -40,19 +40,19 @@ When you use GitHub Copilot, it's important to provide the right context for the
40
40
41
41
## Custom Instructions to GitHub Copilot
42
42
43
-
1. Different models at different times can generate code that does not take every details in your solution, depending on the current context and model capacity.
43
+
1. Different models at different times can generate code that does not take every details in your solution into account, depending on the current context and model capacity.
44
44
45
-
For example, open the file **src/Basket.API/Grpc/BasketService.cs** and press Ctrl-Alt-I to open Chat view and ask to `create unit tests for this class` and observe the generated code.
45
+
For example, open the file **src/Basket.API/Grpc/BasketService.cs** and press `Ctrl-Alt-I` to open Chat view and ask to `create unit tests for this class` and observe the generated code.
46
46
In most cases, for .NET solutions, it will generate code using `Moq` library for mocking dependencies.
47
47
48
-
2. You can create a custom instructions file to automatically add information to all questions you ask Copilot.
49
-
To this end, create a file **.github/copilot-instructions.md** and add and instruction like `When mocking dependencies in tests, we use NSubstitute.`.
50
-
Close the file and retry the question. Observe, two things:
48
+
2. You can create custom instructions file to automatically add information to all questions you ask Copilot.
49
+
To this end, create a file **.github/copilot-instructions.md** and add instructions like `When mocking dependencies in tests, use NSubstitute.`.
50
+
Close the file and retry the question. Observe two things:
51
51
- GitHub Copilot used two references, the file in focus and the custom instructions file.
52
52
- Dependencies are mocked using `NSubstitute` library.
53
53
54
54
3. Since custom instructions consume model tokens, you should try to write [effective instructions](https://docs.github.com/en/copilot/customizing-copilot/adding-custom-instructions-for-github-copilot#writing-effective-custom-instructions).
55
55
56
-
4. in VS Code, you can temporary switch custom instructions on and off by opening the Setting editor (by using shortcut `Ctrl + ,`, (Linux/Windows) / `Command + ,` (Mac).
56
+
4. in VS Code, you can temporary switch custom instructions on and off by using the Setting editor (shortcut `Ctrl + ,` (Linux/Windows) / `Command + ,` (Mac).
57
57
58
58
Type `instruction file` in the search box and select or clear the **Use Instruction Files** checkbox.
0 commit comments