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
[](https://stand-with-ukraine.pp.ua)
[](https://stand-with-ukraine.pp.ua)
This library makes use of [F# computation expressions](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions) to hide some complexity of `WebApplicationFactory` and provide the user with a *domain specific language* (DSL) for integration tests.
11
+
This library makes use of [F# computation expressions](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions) 🪔✨ to hide some complexity of `WebApplicationFactory` and provide the user with a *domain specific language* (DSL) for integration tests.
12
+
13
+
An "antique" C# API (👴🏽🦖🦕) is also available since v.1.1 for enhanced accessibility 😺.
14
+
15
+
## Documentation
12
16
13
-
A C# API is also available, access the [documentation](https://jkone27.github.io/fsharp-integration-tests/)website for more info on how to use this library.
17
+
Access the [documentation website](https://jkone27.github.io/fsharp-integration-tests/) for more info on how to use this library.
Copy file name to clipboardExpand all lines: docs/index.md
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,10 @@
1
-
# ApiStub.FSharp
1
+
<!--# ApiStub.FSharp-->
2
2
3
3

4
4
5
5
## Easy API Testing 🧞♀️
6
6
7
-
You have an ASP NET NET6+ (NET6 is LTS in 2023) aspnetcore API, and you want to simplify HTTP stubs for [integration
8
-
testing](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-9.0) using `WebApplicationFactory`,
9
-
but you find that a bit cumbersome sometimes?
10
-
11
-
this library is here to help you!
7
+
This library makes use of [F# computation expressions](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions) or CEs to wrap some complexities of `WebApplicationFactory<T>` when setting up `integration tests` for a `.NET` Web app. It comes with a *domain specific language* (DSL) for "mocking" HttpClient factory in integration tests, and more.
12
8
13
9
### Test .NET C# 🤝 from F#
14
10
@@ -36,11 +32,12 @@ sequenceDiagram
36
32
App-->>Test: Response
37
33
</div>
38
34
<br>
35
+
39
36
### HTTP Mocks 🤡
40
37
41
38
It's easy to **mock** those http clients dependencies (with data stubs) during integration tests making use of `ApiStub.FSharp` lib, saving quite some code compared to manually implementing the `WebApplicationFactory<T>` pattern, let's see how below.
42
39
43
-
## F#
40
+
## F# 🦔 ✨
44
41
45
42
*`Program`: to be able to make use of `Program.fs` (e.g. minimal api) as `TestClient<Program>()`, make sure to declare an empty `type Program = end class` on top of your Program module containing the `[<EntryPoint>] main args` method.
46
43
@@ -75,7 +72,7 @@ module Tests =
75
72
}
76
73
```
77
74
78
-
## C# - v.1.1.0
75
+
## C# 🤖 for 👴🏽🦖🦕
79
76
80
77
if you prefer to use C# for testing, some extension methods are provided to use with C# as well:
81
78
@@ -96,9 +93,12 @@ var webAppFactory = new CE.TestClient<Web.Sample.Program>()
96
93
97
94
```
98
95
99
-
## Mechanics
96
+
## Mechanics 👨🏽🔧⚙️
97
+
98
+
This library makes use of [F# computation expressions](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions) to hide some complexity of `WebApplicationFactory` and provide the user with a *domain specific language* (DSL) for integration tests in aspnetcore apps.
99
+
100
+
🪆📦 > The main "idea" behind this library is having a CE builder that wraps the creation of a `russian doll` or `chinese boxes` of HttpHandlers to handle mocking requests to http client instances in your application under test or SUT.
100
101
101
-
This library makes use of [F# computation expressions](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions) to hide some complexity of `WebApplicationFactory` and provide the user with a *domain specific language* (DSL) for integration tests in aspnetcore apps.
102
102
The best way to understand how it all works is checking the [code](https://github.com/jkone27/fsharp-integration-tests/blob/249c3244cd7e20e2168b82a49b6e7e14f2ad1004/ApiStub.FSharp/CE.fs#L176) and this member CE method `GetFactory()` in scope.
103
103
104
104
If you have ideas for improvements feel free to open an issue/discussion!
@@ -287,8 +287,15 @@ module Tests =
287
287
* feel free to get in touch, to fork and check out the repo
288
288
* test and find use cases for this library, testing in F# is awesome!!!!
289
289
290
-
### References
290
+
### References 📚
291
291
292
292
* more info on [F# xunit testing](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-dotnet-test).
293
293
* more general info on aspnetcore integration testing if you use [Nunit](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-nunit) instead.
294
294
*[aspnetcore integration testing](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-7.0) docs in C#
[](https://stand-with-ukraine.pp.ua)
0 commit comments