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
* Remove files
In preparation to refactor of the files
* Refactor names
* Updated README.md with suggestion.
Suggestion how the change could sound.
* Update sample project
* Update string reference
* Update project description
* Update for documentation with new naming
* Add credit reference
* Added issue reference
* Update reference to version that would work
* Remove issue link
* Move from Mocking to TestDoubles folder
* Update sample project to use new folder for test doubles
* Fix template project
* Moved tests for bunit.web
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ List of new features.
13
13
List of changes in existing functionality.
14
14
15
15
-`TestContextBase.Dispose` made virtual to allow inheritor's to override it. By [@SimonCropp](https://github.com/SimonCropp) in [#137](https://github.com/egil/bunit/pull/137).
16
+
- Changed naming convention for JSMock feature. All classes and methods containing `Js` (meaning JavaScript) renamed to `JS`. By [yourilima](https://github.com/yourilima) in [#150](https://github.com/egil/bUnit/pull/150)
Copy file name to clipboardExpand all lines: docs/site/docs/csharp-test-examples.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -396,11 +396,11 @@ public class ThemedButtonTest : ComponentTestFixture
396
396
-`Test002` above uses the `CascadingValue(object value)` helper method to pass an **unnamed** cascading value to the CUT.
397
397
-`Test003` above demonstrates how multiple (named) cascading values can be passed to a component under test.
398
398
399
-
## Testing components that use on `IJsRuntime`
399
+
## Testing components that use on `IJSRuntime`
400
400
401
401
It is not uncommon to have components use Blazor's JSInterop functionality to call JavaScript, e.g. after first render.
402
402
403
-
To make it easy to mock calls to JavaScript, the library comes with a `IJsRuntime` mocking helper, that allows you to specify return how JSInterop calls should be handled, and to verify that they have happened.
403
+
To make it easy to mock calls to JavaScript, the library comes with a `IJSRuntime` mocking helper, that allows you to specify return how JSInterop calls should be handled, and to verify that they have happened.
404
404
405
405
If you have more complex mocking needs, you could look to frameworks like [Moq](https://github.com/Moq) or [JustMock Lite](https://github.com/telerik/JustMockLite), which both work nicely with bUnit.
406
406
@@ -441,10 +441,10 @@ public class WikiSearchTest : ComponentTestFixture
441
441
publicvoidTest001()
442
442
{
443
443
// Arrange
444
-
// Registered the MockJsRuntime in "Loose" mode with the service provider used when rendering components.
445
-
//JsRuntimeMockMode.Loose is the default. It configures the mock to just return the default
444
+
// Registered the MockJSRuntime in "Loose" mode with the service provider used when rendering components.
445
+
//JSRuntimeMockMode.Loose is the default. It configures the mock to just return the default
446
446
// value for whatever is requested in a InvokeAsync call if no call has explicitly been set up.
447
-
varjsMock=Services.AddMockJsRuntime();
447
+
varjsMock=Services.AddMockJSRuntime();
448
448
449
449
// Act - render the WikiSearch component
450
450
varcut=RenderComponent<WikiSearch>();
@@ -460,10 +460,10 @@ public class WikiSearchTest : ComponentTestFixture
460
460
publicvoidTest002()
461
461
{
462
462
// Arrange
463
-
// Registered the MockJsRuntime in "strict" mode with the service provider used when rendering components.
464
-
//JsRuntimeMockMode.Strict mode configures the mock to throw an error if it receives an InvokeAsync call
463
+
// Registered the MockJSRuntime in "strict" mode with the service provider used when rendering components.
464
+
//JSRuntimeMockMode.Strict mode configures the mock to throw an error if it receives an InvokeAsync call
@@ -486,7 +486,7 @@ public class WikiSearchTest : ComponentTestFixture
486
486
}
487
487
```
488
488
489
-
-`Test001` just injects the mock in "Loose" mode. It means it will only returns a `default(TValue)` for calls to `InvokeAsync<TValue>(...)` it receives. This allows us to test components that expects a `IJsRuntime` to be injected, but where the test we want to perform isn't dependent on it providing any specific return value.
489
+
-`Test001` just injects the mock in "Loose" mode. It means it will only returns a `default(TValue)` for calls to `InvokeAsync<TValue>(...)` it receives. This allows us to test components that expects a `IJSRuntime` to be injected, but where the test we want to perform isn't dependent on it providing any specific return value.
490
490
491
491
In "Loose" mode it is still possible to call `VerifyInvoke(identifier)` and assert against the expected invocation.
492
492
@@ -497,7 +497,7 @@ public class WikiSearchTest : ComponentTestFixture
497
497
498
498
### Verifying element references passed to InvokeAsync
499
499
500
-
If you want to verify that a element reference (`ElementReference`) passed to a IJsRuntime.InvokeAsync call is references the expected DOM element, you can do so with the `ShouldBeElementReferenceTo()` assert helper.
500
+
If you want to verify that a element reference (`ElementReference`) passed to a IJSRuntime.InvokeAsync call is references the expected DOM element, you can do so with the `ShouldBeElementReferenceTo()` assert helper.
501
501
502
502
For example, consider the [FocussingInput.razor](https://github.com/egil/razor-components-testing-library/tree/main/sample/src/Components/FocussingInput.razor) component, which looks like this:
503
503
@@ -530,8 +530,8 @@ public class FocussingInputTest : ComponentTestFixture
530
530
[Fact(DisplayName="After first render, the new input field has focus")]
531
531
publicvoidTest001()
532
532
{
533
-
// Arrange - add the IJsRuntime mock
534
-
varjsRtMock=Services.AddMockJsRuntime();
533
+
// Arrange - add the IJSRuntime mock
534
+
varjsRtMock=Services.AddMockJSRuntime();
535
535
536
536
// Act - render the FocussingInput component, causing
537
537
// the OnAfterRender(firstRender: true) to be called
0 commit comments