-
Notifications
You must be signed in to change notification settings - Fork 7
Prepare documentation #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
piotrzajac
wants to merge
8
commits into
master
Choose a base branch
from
feature/docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a413ae9
Prepare documentation
piotrzajac b2310f4
Separate Parameter Configuration Attributes from Test Method Attributes
piotrzajac e72d848
Improve wording
piotrzajac 51505db
Improve wording
piotrzajac 867872e
Introduce mkdocs configuration
piotrzajac 6299b5a
Introduce github actions for building and publishing documentation
piotrzajac b937bee
Remove Badges
piotrzajac de22e77
Merge branch 'master' into feature/docs
piotrzajac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| name: Build Documentation | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| paths: | ||
| - 'docs/**' | ||
| - 'mkdocs.yml' | ||
| - '.github/workflows/docs.yml' | ||
| pull_request: | ||
| branches: [ master ] | ||
| paths: | ||
| - 'docs/**' | ||
| - 'mkdocs.yml' | ||
| - '.github/workflows/docs.yml' | ||
| workflow_dispatch: | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: pwsh | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
| steps: | ||
| - name: 📥 checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: 🐍 setup python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: 📦 install mkdocs and material theme | ||
| run: | | ||
| $ErrorActionPreference = 'stop' | ||
| pip install mkdocs-material | ||
| if ($LastExitCode -ne 0) { | ||
| throw "pip install failed with exit code $LastExitCode" | ||
| } | ||
|
|
||
| - name: 🏗️ build documentation | ||
| run: | | ||
| $ErrorActionPreference = 'stop' | ||
| mkdocs build | ||
| if ($LastExitCode -ne 0) { | ||
| throw "mkdocs build failed with exit code $LastExitCode" | ||
| } | ||
|
|
||
| - name: 📤 upload pages artifact | ||
| id: artifacts | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: ./site | ||
|
|
||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.artifacts.outputs.page_url }} | ||
| runs-on: ubuntu-latest | ||
| needs: [build] | ||
| if: ${{ github.ref_name == 'master' && needs.build.result == 'success' }} | ||
| steps: | ||
| - name: 📤 Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # AutoMockData Attribute | ||
|
|
||
| Provides auto-generated data specimens generated by [AutoFixture](https://github.com/AutoFixture/AutoFixture) with a mocking library as an extension to xUnit.net's `Theory` attribute. | ||
|
|
||
| ## Arguments | ||
|
|
||
| - `IgnoreVirtualMembers` - disables generation of members marked as `virtual` (default: `false`) | ||
|
|
||
| ## Example | ||
|
|
||
| ```csharp | ||
| [Theory] | ||
| [AutoMockData] | ||
| public void GivenCurrencyConverter_WhenConvertToPln_ThenMustReturnCorrectConvertedAmount( | ||
| string testCurrencySymbol, | ||
| [Frozen] ICurrencyExchangeProvider currencyProvider, | ||
| CurrencyConverter currencyConverter) | ||
| { | ||
| // Arrange | ||
| Mock.Get(currencyProvider) | ||
| .Setup(cp => cp.GetCurrencyExchangeRate(testCurrencySymbol)) | ||
| .Returns(100M); | ||
|
|
||
| // Act | ||
| decimal result = currencyConverter.ConvertToPln(testCurrencySymbol, 100M); | ||
|
|
||
| // Assert | ||
| Assert.Equal(10000M, result); | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # CustomizeWith Attribute | ||
|
|
||
| An attribute that can be applied to parameters in an `AutoDataAttribute`-driven `Theory` to apply additional customization when the `IFixture` creates an instance of that type. | ||
|
|
||
| ## Arguments | ||
|
|
||
| - `IncludeParameterType` - indicates whether attribute target parameter `Type` should be included as a first argument when creating customization; by default set to `false` | ||
|
|
||
| **Caution:** Order is important! Applying `CustomizeWith` attribute to the subsequent parameter makes preceding parameters of the same type to be created without specified customization and the particular parameter with the specified customization. | ||
|
|
||
| ## Example | ||
|
|
||
| ```csharp | ||
| public class LocalDatesCustomization : ICustomization | ||
| { | ||
| public void Customize(IFixture fixture) | ||
| { | ||
| fixture.Register(() => LocalDate.FromDateTime(fixture.Create<DateTime>())); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```csharp | ||
| [Theory] | ||
| [InlineAutoMockData("USD")] | ||
| [InlineAutoMockData("EUR")] | ||
| public void GivenCurrencyConverter_WhenConvertToPlnAtParticularDay_ThenMustReturnCorrectConvertedAmount( | ||
| string testCurrencySymbol, | ||
| [CustomizeWith(typeof(LocalDatesCustomization))] LocalDate day, | ||
| [Frozen] ICurrencyExchangeProvider currencyProvider, | ||
| CurrencyConverter currencyConverter) | ||
| { | ||
| // Arrange | ||
| Mock.Get(currencyProvider) | ||
| .Setup(cp => cp.GetCurrencyExchangeRate(testCurrencySymbol, day)) | ||
| .Returns(100M); | ||
|
|
||
| // Act | ||
| decimal result = currencyConverter.ConvertToPln(testCurrencySymbol, 100M, day); | ||
|
|
||
| // Assert | ||
| Assert.Equal(10000M, result); | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # CustomizeWith\<T> Attribute | ||
|
|
||
| A generic version of the `CustomizeWith` attribute has been introduced for ease of use. The same rules apply as for the non-generic version. | ||
|
|
||
| ## Example | ||
|
|
||
| ```csharp | ||
| public class EmptyCollectionCustomization : ICustomization | ||
| { | ||
| public EmptyCollectionCustomization(Type reflectedType) | ||
| { | ||
| this.ReflectedType = reflectedType; | ||
| } | ||
|
|
||
| public Type ReflectedType { get; } | ||
|
|
||
| public void Customize(IFixture fixture) | ||
| { | ||
| var emptyArray = Array.CreateInstance(this.ReflectedType.GenericTypeArguments.Single(), 0); | ||
|
|
||
| fixture.Customizations.Add( | ||
| new FilteringSpecimenBuilder( | ||
| new FixedBuilder(emptyArray), | ||
| new ExactTypeSpecification(this.ReflectedType))); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```csharp | ||
| public sealed class EmptyCollectionAttribute : CustomizeWithAttribute<EmptyCollectionCustomization> | ||
| { | ||
| public EmptyCollectionAttribute() | ||
| { | ||
| this.IncludeParameterType = true; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```csharp | ||
| [Theory] | ||
| [AutoData] | ||
| public void CustomizeWithAttributeUsage( | ||
| IList<string> firstStore, | ||
| [EmptyCollection] IList<string> secondStore, | ||
| IList<string> thirdStore, | ||
| IList<int?> fourthStore) | ||
| { | ||
| Assert.NotEmpty(firstStore); | ||
| Assert.Empty(secondStore); | ||
| Assert.Empty(thirdStore); | ||
| Assert.NotEmpty(fourthStore); | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Except Attribute | ||
|
|
||
| Ensures that values from outside the specified list will be generated. | ||
|
|
||
| ```csharp | ||
| [Theory] | ||
| [AutoData] | ||
| public void ExceptAttributeUsage( | ||
| [Except(DayOfWeek.Saturday, DayOfWeek.Sunday)] DayOfWeek workday) | ||
| { | ||
| Assert.True(workday is >= DayOfWeek.Monday and <= DayOfWeek.Friday); | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # IgnoreVirtualMembers Attribute | ||
|
|
||
| An attribute that can be applied to parameters in an `AutoDataAttribute`-driven `Theory` to indicate that the parameter value should not have `virtual` properties populated when the `IFixture` creates an instance of that type. | ||
|
|
||
| This attribute allows disabling the generation of members marked as `virtual` on a decorated type, whereas `IgnoreVirtualMembers` arguments of mocking attributes mentioned above disable such a generation for all types created by `IFixture`. | ||
|
|
||
| **Caution:** Order is important! Applying `IgnoreVirtualMembers` attribute to the subsequent parameter makes preceding parameters of the same type to have `virtual` properties populated and the particular parameter with the following ones of the same type to have `virtual` properties unpopulated. | ||
|
|
||
| ## Example | ||
|
|
||
| ```csharp | ||
| public class User | ||
| { | ||
| public string Name { get; set; } | ||
| public virtual Address Address { get; set; } | ||
| } | ||
| ``` | ||
|
|
||
| ```csharp | ||
| [Theory] | ||
| [AutoData] | ||
| public void IgnoreVirtualMembersUsage( | ||
| User firstUser, | ||
| [IgnoreVirtualMembers] User secondUser, | ||
| User thirdUser) | ||
| { | ||
| Assert.NotNull(firstUser.Name); | ||
| Assert.NotNull(firstUser.Address); | ||
|
|
||
| Assert.NotNull(secondUser.Name); | ||
| Assert.Null(secondUser.Address); | ||
|
|
||
| Assert.NotNull(thirdUser.Name); | ||
| Assert.Null(thirdUser.Address); | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Attributes Overview | ||
|
|
||
| This section describes the main attributes provided by AutoFixture.XUnit2.AutoMock for use in your xUnit tests: | ||
|
|
||
| ## Test Method Attributes | ||
|
|
||
| - [AutoMockData](auto-mock-data-attribute.md): Provides auto-generated data specimens using AutoFixture and a mocking library. | ||
| - [InlineAutoMockData](inline-auto-mock-data-attribute.md): Combines inline values with auto-generated data specimens. | ||
| - [MemberAutoMockData](member-auto-mock-data-attribute.md): Uses static members as data sources, combined with auto-generated data. | ||
|
|
||
| ## Parameter Configuration Attributes | ||
|
|
||
| - [IgnoreVirtualMembers](ignore-virtual-members-attribute.md): Disables generation of virtual members for a parameter or globally. | ||
| - [CustomizeWith](customize-with-attribute.md): Applies additional customization to a parameter. | ||
| - [CustomizeWith\<T>](customize-with-t-attribute.md): Generic version of CustomizeWith for ease of use. | ||
|
|
||
| ## Data Filtering Attributes | ||
|
|
||
| - [Except](except-attribute.md): Ensures values from outside the specified list will be generated. | ||
| - [PickFromRange](pick-from-range-attribute.md): Ensures only values from a specified range will be generated. | ||
| - [PickNegative](pick-negative-attribute.md): Ensures only negative values will be generated. | ||
| - [PickFromValues](pick-from-values-attribute.md): Ensures only values from the specified list will be generated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # InlineAutoMockData Attribute | ||
|
|
||
| Provides a data source for a `Theory`, with the data coming from inline values combined with auto-generated data specimens generated by [AutoFixture](https://github.com/AutoFixture/AutoFixture) with a mocking library. | ||
|
|
||
| ## Arguments | ||
|
|
||
| - `IgnoreVirtualMembers` - disables generation of members marked as `virtual` (default: `false`) | ||
|
|
||
| ## Example | ||
|
|
||
| ```csharp | ||
| [Theory] | ||
| [InlineAutoMockData("USD", 3, 10, 30)] | ||
| [InlineAutoMockData("EUR", 4, 20, 80)] | ||
| public void GivenCurrencyConverter_WhenConvertToPln_ThenMustReturnCorrectConvertedAmount( | ||
| string testCurrencySymbol, | ||
| decimal exchangeRate, | ||
| decimal currencyAmount, | ||
| decimal expectedPlnAmount, | ||
| [Frozen] ICurrencyExchangeProvider currencyProvider, | ||
| CurrencyConverter currencyConverter) | ||
| { | ||
| // Arrange | ||
| Mock.Get(currencyProvider) | ||
| .Setup(cp => cp.GetCurrencyExchangeRate(testCurrencySymbol)) | ||
| .Returns(exchangeRate); | ||
|
|
||
| // Act | ||
| decimal result = currencyConverter.ConvertToPln(testCurrencySymbol, currencyAmount); | ||
|
|
||
| // Assert | ||
| Assert.Equal(expectedPlnAmount, result); | ||
| } | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment.urlpoints to a non-existent output – workflow will failactions/upload-pages-artifact(stepartifacts) doesn’t expose apage_urloutput.The
page_urlcomes fromactions/deploy-pages, which you already invoke in the step with iddeployment. Reference that step instead:Without this change
actionlint(and the runtime run) will error out with “property … is not defined”.📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
70-70: property "artifacts" is not defined in object type {deployment: {conclusion: string; outcome: string; outputs: {page_url: string}}}
(expression)
🤖 Prompt for AI Agents