Skip to content

Commit 9b9c1e4

Browse files
committed
Updated cshtml highlight script
1 parent 7e92257 commit 9b9c1e4

12 files changed

Lines changed: 66 additions & 58 deletions

docs/site/docs/getting-started/fixture-details.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bUnit's <xref:Bunit.Fixture> component provides different parameters you can set
1414

1515
All the parameters the <xref:Bunit.Fixture> component support is shown in the listing below:
1616

17-
[!code-html[](../../../samples/tests/razor/AllFixtureParameters.razor)]
17+
[!code-cshtml[](../../../samples/tests/razor/AllFixtureParameters.razor)]
1818

1919
**Setup and Test methods:**
2020

@@ -49,7 +49,7 @@ The other parameters affect how the test runs, and how it is displayed in e.g. V
4949

5050
The <xref:Bunit.Fixture> component only accepts the <xref:Bunit.ComponentUnderTest> and <xref:Bunit.Fragment> components as its child content. All other components and markup are ignored. E.g.:
5151

52-
[!code-html[](../../../samples/tests/razor/FixtureWithCutAndFragments.html)]
52+
[!code-cshtml[](../../../samples/tests/razor/FixtureWithCutAndFragments.html)]
5353

5454
Here are the rules for the <xref:Bunit.Fixture> components child content:
5555

@@ -87,7 +87,7 @@ The generic versions of <xref:Bunit.Fixture.GetComponentUnderTest``1> and <xref:
8787

8888
Let's look at a complete example, where we have a simple task list component, `<SimpleTodo>`, listed below, that have a service injected, receive a cascading value, and changes between renders:
8989

90-
[!code-html[SimpleTodo.razor](../../../samples/components/SimpleTodo.razor)]
90+
[!code-cshtml[SimpleTodo.razor](../../../samples/components/SimpleTodo.razor)]
9191

9292
In the test, we want to verify that:
9393

@@ -97,7 +97,7 @@ In the test, we want to verify that:
9797

9898
The test looks like this:
9999

100-
[!code-html[SimpleTodoTest.razor](../../../samples/tests/razor/SimpleTodoTest.razor?highlight=4,5,8-10,13,20,29,30,35-37,44)]
100+
[!code-cshtml[SimpleTodoTest.razor](../../../samples/tests/razor/SimpleTodoTest.razor?highlight=4,5,8-10,13,20,29,30,35-37,44)]
101101

102102
Let's look at what's going on in this test:
103103

docs/site/docs/getting-started/snapshottest-details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bUnit's support for snapshot testing comes with the <xref:Bunit.SnapshotTest> co
1717

1818
All the parameters the <xref:Bunit.SnapshotTest> component support is shown in the listing below:
1919

20-
[!code-html[](../../../samples/tests/razor/AllSnapshotTestParameters.razor)]
20+
[!code-cshtml[](../../../samples/tests/razor/AllSnapshotTestParameters.razor)]
2121

2222
Let us go over each of these:
2323

docs/site/docs/getting-started/writing-csharp-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Rendering a component happens through bUnit's <xref:Bunit.TestContext>, and the
1515

1616
This is a simple example, that tests the following `<HelloWorld>` component:
1717

18-
[!code-html[HelloWorld.razor](../../../samples/components/HelloWorld.razor)]
18+
[!code-cshtml[HelloWorld.razor](../../../samples/components/HelloWorld.razor)]
1919

2020
# [xUnit](#tab/xunit)
2121

docs/site/docs/getting-started/writing-razor-tests.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A test for a Blazor component can be written in a Blazor component, using a mix
1919

2020
Razor tests are written in Blazor test components. To make our life's a little easier, let us first set up a `_Imports.razor` file, with the using statements we are going to be using throughout our tests. Simply add the following `_Imports.razor` to the root folder where you will be placing your Blazor test components:
2121

22-
[!code-html[_Imports.razor](../../../samples/tests/razor/_Imports.razor#L4-)]
22+
[!code-cshtml[_Imports.razor](../../../samples/tests/razor/_Imports.razor#L4-)]
2323

2424
With that created, we are ready to create our first Razor test.
2525

@@ -29,19 +29,19 @@ A Blazor test component is conceptually very similar to a regular test class in
2929

3030
Besides that, Blazor test components has to inherit from <xref:Bunit.TestComponentBase>, e.g.:
3131

32-
[!code-html[](../../../samples/tests/razor/HelloWorldTest.razor#L1)]
32+
[!code-cshtml[](../../../samples/tests/razor/HelloWorldTest.razor#L1)]
3333

3434
The following two sections will show how to create tests using bUnit's <xref:Bunit.Fixture> and <xref:Bunit.SnapshotTest> components.
3535

3636
### Creating a Test using the `<Fixture>` Component
3737

3838
Let's see a simple example, where we test the following `<HelloWorld>` component using the bUnit <xref:Bunit.Fixture> component:
3939

40-
[!code-html[HelloWorld.razor](../../../samples/components/HelloWorld.razor)]
40+
[!code-cshtml[HelloWorld.razor](../../../samples/components/HelloWorld.razor)]
4141

4242
Here is the Razor code that tests the `<HelloWorld>` component:
4343

44-
[!code-html[HelloWorldTest.razor](../../../samples/tests/razor/HelloWorldTest.razor#L1-L19)]
44+
[!code-cshtml[HelloWorldTest.razor](../../../samples/tests/razor/HelloWorldTest.razor#L1-L19)]
4545

4646
Let's break down what is going on in this test:
4747

@@ -65,11 +65,11 @@ In snapshot testing, you declare your input (e.g. one or more component under te
6565

6666
Let's see a simple example, where we test the following `<HelloWorld>` component using the bUnit <xref:Bunit.SnapshotTest> component:
6767

68-
[!code-html[HelloWorld.razor](../../../samples/components/HelloWorld.razor)]
68+
[!code-cshtml[HelloWorld.razor](../../../samples/components/HelloWorld.razor)]
6969

7070
Here is the Razor code that tests the `<HelloWorld>` component:
7171

72-
[!code-html[HelloWorldTest.razor](../../../samples/tests/razor/HelloWorldTest.razor?range=1-2,21-28)]
72+
[!code-cshtml[HelloWorldTest.razor](../../../samples/tests/razor/HelloWorldTest.razor?range=1-2,21-28)]
7373

7474
Let's break down what is going on in this test with the <xref:Bunit.SnapshotTest> component:
7575

@@ -88,7 +88,7 @@ Since we are declaring our component under test in Razor syntax, passing paramet
8888

8989
In this example, we are passing both attribute parameters and child content to the component under test, in this case, a basic `<Alert>` component:
9090

91-
[!code-html[](../../../samples/tests/razor/PassingParametersToComponents.razor)]
91+
[!code-cshtml[](../../../samples/tests/razor/PassingParametersToComponents.razor)]
9292

9393
Injecting services into the components under test is covered on the <xref:inject-services> page.
9494

docs/site/docs/interaction/awaiting-async-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The [`WaitForState(Func<Boolean>, TimeSpan?)`](xref:Bunit.RenderedFragmentWaitFo
2020
2121
Let us look at an example. Consider the following `<AsyncData>` component, who awaits an async `TextService` in its `OnInitializedAsync()` life-cycle method. When the service returns the data, the component will automatically re-render, to update its rendered markup.
2222

23-
[!code-html[AsyncData.razor](../../../samples/components/AsyncData.razor)]
23+
[!code-cshtml[AsyncData.razor](../../../samples/components/AsyncData.razor)]
2424

2525
To test the `<AsyncData>` component, do the following:
2626

docs/site/docs/interaction/trigger-event-handlers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To invoke an event handler on an element, first find the element in the componen
3333

3434
Let's look at a common example, where a `@onclick` event handler is invoked. The example will use the `<ClickMe>` component listed here:
3535

36-
[!code-html[ClickMe.razor](../../../samples/components/ClickMe.razor)]
36+
[!code-cshtml[ClickMe.razor](../../../samples/components/ClickMe.razor)]
3737

3838
To trigger the `@onclick` `ClickHandler` event handler method in the `<ClickMe>` component, do the following:
3939

@@ -43,7 +43,7 @@ To trigger the `@onclick` `ClickHandler` event handler method in the `<ClickMe>`
4343

4444
# [Razor test code](#tab/razor)
4545

46-
[!code-html[ClickMeTest.razor](../../../samples/tests/razor/ClickMeTest.razor?highlight=17-19)]
46+
[!code-cshtml[ClickMeTest.razor](../../../samples/tests/razor/ClickMeTest.razor?highlight=17-19)]
4747

4848
***
4949

docs/site/docs/interaction/trigger-renders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If you receive this error, you need to invoke your method inside an `Action` del
4747

4848
Consider the `<ImparativeCalc>` component listed below:
4949

50-
[!code-html[ImparativeCalc.razor](../../../samples/components/ImparativeCalc.razor)]
50+
[!code-cshtml[ImparativeCalc.razor](../../../samples/components/ImparativeCalc.razor)]
5151

5252
To invoke the `Calculate()` method on the component instance, do the following:
5353

docs/site/docs/providing-input/inject-services-into-components.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In bUnit, you register the services in the `Services` collection _before_ you re
1313

1414
The following sections shows how to do this in C# and Razor based tests. The examples will test the `<WeatherForecasts>` component listed below, that depends on the `IWeatherForecastService` service, injected in line 1:
1515

16-
[!code-html[WeatherForecasts.razor](../../../samples/components/WeatherForecasts.razor?highlight=1)]
16+
[!code-cshtml[WeatherForecasts.razor](../../../samples/components/WeatherForecasts.razor?highlight=1)]
1717

1818
## Injecting Services in C# Based Tests
1919

@@ -30,15 +30,15 @@ The highlighted line shows how the `IWeatherForecastService` is registered in th
3030

3131
Here is a Razor based test that registers the `IWeatherForecastService` in the `Services` collection during the `Setup` methods, which is needed by the `<WeatherForecasts>` component listed above.
3232

33-
[!code-html[WeatherForecastsTest.razor](../../../samples/tests/razor/WeatherForecastsTest.razor?highlight=10-13)]
33+
[!code-cshtml[WeatherForecastsTest.razor](../../../samples/tests/razor/WeatherForecastsTest.razor?highlight=10-13)]
3434

3535
The highlighted line shows how the `IWeatherForecastService` is registered, using the standard .NET Core DI services method, [`AddSingleton`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicecollectionserviceextensions.addsingleton?view=dotnet-plat-ext-3.1#Microsoft_Extensions_DependencyInjection_ServiceCollectionServiceExtensions_AddSingleton__1_Microsoft_Extensions_DependencyInjection_IServiceCollection___0_).
3636

3737
This can either be done via the `Fixture`'s `Setup` method as in this example, if you want to separate the service registration from the test method, or it can be done in the test method _before_ calling `GetComponentUnderTest()`.
3838

3939
In the following example shows how to do this with `<SnapshotTest>` tests:
4040

41-
[!code-html[WeatherForecastsTest.razor](../../../samples/tests/razor/WeatherForecastsSnapshotTest.html?highlight=5-8)]
41+
[!code-cshtml[WeatherForecastsTest.razor](../../../samples/tests/razor/WeatherForecastsSnapshotTest.html?highlight=5-8)]
4242

4343
> [!TIP]
4444
> If multiple Razor tests share the same setup logic, they can share the same dedicated setup method as well.

docs/site/docs/providing-input/passing-parameters-to-components.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ All of these examples do the same thing, here is what is going on:
7070
7171
# [Razor test code](#tab/razor)
7272
73-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L3-L7)]
73+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L3-L7)]
7474
7575
This is just regular Blazor parameter passing, which is the same for both `Fixture` and `SnapshotTest` razor tests.
7676
@@ -95,7 +95,7 @@ These examples o the same thing, here is what is going on:
9595
9696
# [Razor test code](#tab/razor)
9797
98-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L9-L14)]
98+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L9-L14)]
9999
100100
This is just regular Blazor parameter passing, which is the same for both `Fixture` and `SnapshotTest` razor tests.
101101
@@ -122,7 +122,7 @@ These examples do the same thing, here is what is going on:
122122
123123
# [Razor test code](#tab/razor)
124124
125-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L16-L22)]
125+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L16-L22)]
126126
127127
This is just regular Blazor child content parameter passing, e.g. as child content to the component under test, which is the same for both `Fixture` and `SnapshotTest` razor tests.
128128
@@ -143,7 +143,7 @@ These examples do the same thing, here is what is going on:
143143
144144
# [Razor test code](#tab/razor)
145145
146-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L24-L30)]
146+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L24-L30)]
147147
148148
This is just regular Blazor child content parameter passing, where the `<Counter />` component is declared inside the component under test. This is the same for both `Fixture` and `SnapshotTest` razor tests.
149149
@@ -166,7 +166,7 @@ These examples do the same thing, here is what is going on:
166166
167167
# [Razor test code](#tab/razor)
168168
169-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L32-L40)]
169+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L32-L40)]
170170
171171
This is just regular Blazor child content parameter passing, where the `<Alert>` component is declared inside the component under test, and any parameters is passed to it like normal in Blazor. This is the same for both `Fixture` and `SnapshotTest` razor tests.
172172
@@ -184,7 +184,7 @@ Passing a mix of markup and a component to a `ChildContent` parameter is current
184184
185185
# [Razor test code](#tab/razor)
186186
187-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L42-L51)]
187+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L42-L51)]
188188
189189
This is just regular Blazor child content parameter passing, where regular HTML markup and an `<Alert>` component is declared inside the component under test, and any parameters is passed to it like normal in Blazor. This is the same for both `Fixture` and `SnapshotTest` razor tests.
190190
@@ -213,7 +213,7 @@ These examples do the same thing, here is what is going on:
213213
214214
# [Razor test code](#tab/razor)
215215
216-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L53-L61)]
216+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L53-L61)]
217217
218218
This is just regular Blazor `RenderFragment` parameter passing, e.g. as markup in the component under test's `<Content>` element, which is the same for both `Fixture` and `SnapshotTest` razor tests.
219219
@@ -234,7 +234,7 @@ These examples do the same thing, here is what is going on:
234234
235235
# [Razor test code](#tab/razor)
236236
237-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L63-L71)]
237+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L63-L71)]
238238
239239
This is just regular Blazor child content parameter passing, where the `<Counter />` component is declared inside component under test's `<Content>` element. This is the same for both `Fixture` and `SnapshotTest` razor tests.
240240
@@ -257,7 +257,7 @@ These examples do the same thing, here is what is going on:
257257
258258
# [Razor test code](#tab/razor)
259259
260-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L73-L83)]
260+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L73-L83)]
261261
262262
This is just regular Blazor `RenderFragment` parameter passing, where the `<Alert>` component is declared inside the component under test's `<Content>` element, and any parameters is passed to it like normal in Blazor. This is the same for both `Fixture` and `SnapshotTest` razor tests.
263263
@@ -275,7 +275,7 @@ Passing a mix of markup and a component to a `RenderFragment` parameter is curre
275275
276276
# [Razor test code](#tab/razor)
277277
278-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L85-L96)]
278+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L85-L96)]
279279
280280
This is just regular Blazor `RenderFragment` parameter passing, where regular HTML markup and an `<Alert>` component is declared inside the component under test's `<Content>` element, and any parameters is passed to it like normal in Blazor. This is the same for both `Fixture` and `SnapshotTest` razor tests.
281281
@@ -306,7 +306,7 @@ The delegate creates a simple markup string in both examples.
306306
307307
# [Razor test code](#tab/razor)
308308
309-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L98-L109)]
309+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L98-L109)]
310310
311311
This is just regular Blazor `RenderFragment<TValue>` parameter passing, in this case, to the `Template` parameter. This is the same for both `Fixture` and `SnapshotTest` razor tests.
312312
@@ -329,7 +329,7 @@ These examples do the same thing, i.e. create a template which consist of a `<di
329329
330330
# [Razor test code](#tab/razor)
331331
332-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L108-L118)]
332+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L108-L118)]
333333
334334
This is just regular Blazor `RenderFragment<TValue>` parameter passing, in this case, to the `Template` parameter. This is the same for both `Fixture` and `SnapshotTest` razor tests.
335335
@@ -351,7 +351,7 @@ These examples do the same thing, i.e. pass in the parameter `some-unknown-param
351351
352352
# [Razor test code](#tab/razor)
353353
354-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L120-L124)]
354+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L120-L124)]
355355
356356
This is just regular Blazor parameter passing, which is the same for both `Fixture` and `SnapshotTest` razor tests. In this case, the parameter `some-unknown-param` with the value `a value` is passed to the component under test.
357357
@@ -381,7 +381,7 @@ These examples do the same thing, i.e. pass in variable `isDarkTheme` to the cas
381381
382382
# [Razor test code](#tab/razor)
383383
384-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L126-L132)]
384+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L126-L132)]
385385
386386
This is just regular Blazor cascading value parameter passing, which is the same for both `Fixture` and `SnapshotTest` razor tests. In this case, the `<CascadingValue>` component is used to pass the unnamed parameter value.
387387
@@ -402,7 +402,7 @@ These examples do the same thing, i.e. pass in value `Egil Hansen` to the cascad
402402
403403
# [Razor test code](#tab/razor)
404404
405-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L134-L140)]
405+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L134-L140)]
406406
407407
This is just regular Blazor cascading value parameter passing, which is the same for both `Fixture` and `SnapshotTest` razor tests. In this case, the `<CascadingValue>` component is used to pass a named parameter value, since both the `Name` and `Value` parameters are specified.
408408
@@ -424,7 +424,7 @@ These examples do the same thing, i.e. pass both the unnamed `IsDarkTheme` casca
424424
425425
# [Razor test code](#tab/razor)
426426
427-
[!code-html[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L142-L152)]
427+
[!code-cshtml[](../../../samples/tests/razor/AllKindsOfParamsTest.razor#L142-L152)]
428428
429429
This is just regular Blazor cascading value parameter passing, which is the same for both `Fixture` and `SnapshotTest` razor tests. In this case, multiple `<CascadingValue>` components is used to pass the unnamed and named cascading parameter values to the component.
430430
@@ -442,7 +442,7 @@ These examples do the same thing, i.e. rendering the `<HelloWorld>` component in
442442
443443
# [Razor test code](#tab/razor)
444444
445-
[!code-html[](../../../samples/tests/razor/NestedComponentTest.razor#L3-)]
445+
[!code-cshtml[](../../../samples/tests/razor/NestedComponentTest.razor#L3-)]
446446
447447
This is just regular Blazor child content parameter passing, where one component is rendered inside another, i.e. the `<HelloWorld>` component inside the `<Wrapper>` component.
448448

docs/site/docs/verification/async-assertion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The [`WaitForAssertion(Action, TimeSpan?)`](xref:Bunit.RenderedFragmentWaitForHe
2020
2121
Let us look at an example. Consider the following `<AsyncData>` component, who awaits an async `TextService` in its `OnInitializedAsync()` life-cycle method. When the service returns the data, the component will automatically re-render, to update its rendered markup.
2222

23-
[!code-html[AsyncData.razor](../../../samples/components/AsyncData.razor)]
23+
[!code-cshtml[AsyncData.razor](../../../samples/components/AsyncData.razor)]
2424

2525
To test the `<AsyncData>` component, do the following:
2626

0 commit comments

Comments
 (0)