Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix ResourceQueryFilter constraints and add test cases - #1361

#1361
Open
kumarnitin17 wants to merge 2 commits into
devPHOENIXCONTACT/MORYX-Framework:devfrom
fix/resource-resourcequeryfilterPHOENIXCONTACT/MORYX-Framework:fix/resource-resourcequeryfilterCopy head branch name to clipboard
Open

Fix ResourceQueryFilter constraints and add test cases#1361
kumarnitin17 wants to merge 2 commits into
devPHOENIXCONTACT/MORYX-Framework:devfrom
fix/resource-resourcequeryfilterPHOENIXCONTACT/MORYX-Framework:fix/resource-resourcequeryfilterCopy head branch name to clipboard

Conversation

@kumarnitin17

Copy link
Copy Markdown
Contributor

Summary

  1. Extracted the private ResourceQueryFilter into a new internal class to make it unit testable.
  2. Added a new test project Moryx.AbstractionLayer.Resources.Endpoints.Tests for Resource Endpoints.
  3. Added InternalsVisibleTo to allow unit testing of the internal ResourceQueryFilter class.
  4. Implemented unit tests covering all ReferenceValue constraint scenarios handled by ResourceQueryFilter, including:
  • ReferenceValue.Irrelevant
  • ReferenceValue.NotEmpty
  • ReferenceValue.NullOrEmpty
  1. Reused existing test resources (ReferenceResource, SimpleResource, ReferenceCollectionMock) from Moryx.Resources.Management.Tests to avoid duplicating test infrastructure.

Unit Test Cases

  1. Match_WithIrrelevantReferenceConstraint_ReturnsTrue
  • Verifies that ReferenceValue.Irrelevant always returns true once the reference property is resolved, without evaluating the collection contents.
  1. Match_WithEmptyReferenceCollection_AndNotEmptyConstraint_ReturnsFalse
  • Verifies that an empty reference collection does not satisfy the NotEmpty constraint.
  1. Match_WithNotEmptyReferenceCollection_AndNotEmptyConstraint_ReturnsTrue
  • Verifies that a populated reference collection satisfies the NotEmpty constraint.
  1. Match_WithEmptyReferenceCollection_AndNullOrEmptyConstraint_ReturnsTrue
  • Verifies that an empty reference collection satisfies the NullOrEmpty constraint.
  1. Match_WithNotEmptyReferenceCollection_AndNullOrEmptyConstraint_ReturnsFalse
  • Verifies that a populated reference collection does not satisfy the NullOrEmpty constraint.

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DebugType>full</DebugType>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to add IsPackable - false, Nullable enable and ImplicitUsings enable here. The last to flags are added to all new probjects at least and we should respect the nullable warnings here as well and handle them meaningfully 😊

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the standard project settings:

  • IsPackable=false
  • Nullable=enable
  • ImplicitUsings=enable

This aligns the test project with the configuration used in the other projects and enables nullable reference type checks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot <IsTestProject>true</IsTestProject> unfortunately

Comment thread MORYX-Framework.slnx

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check this file again, looks like you got the line ending issue again

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MORYX-Framework .slnx modification was caused by a line-ending issue. I have reverted the unintended change and updated the PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you copy these classes? 🙈 If you want to reuse them please move them to Moryx.AbstractionLayer.TestTools there is already a tab for resources. Also remove them from the other test project, we don't want them duplicated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classes were duplicated. I moved the shared resource test classes to Moryx.AbstractionLayer.TestTools.Resources and removed the duplicate copies from Moryx.AbstractionLayer.Resources.Endpoints.Tests. The tests now use the shared implementations from TestTools.

}

[Test(Description = "Match returns false when reference collection is empty and constraint is NotEmpty")]
public void Match_WithEmptyReferenceCollection_AndNotEmptyConstraint_ReturnsFalse()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being picky here, please remove the middle _ as it conflicts with the microsoft naming guideline 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the underscores from the test method name to align with the Microsoft naming guidelines.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only meant the middle _ in the name. Please check the guideline yourselves, understand it and apply the naming convention correctly 😊

@kumarnitin17
kumarnitin17 force-pushed the fix/resource-resourcequeryfilter branch from 6f63d2a to 7bc9635 Compare July 23, 2026 17:42
@kumarnitin17 kumarnitin17 self-assigned this Jul 23, 2026
@kumarnitin17 kumarnitin17 added the enhancement New feature or request label Jul 23, 2026
@kumarnitin17 kumarnitin17 added this to the Framework 10.x milestone Jul 23, 2026

return Accepted();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making this internal, it should be tested as a blackbox, there is no need for the production code to make it internal, just for tests is ab bad pattern(i know, we have a lot of them). Its now a good sample that You test implementation instead of behavior. Even its internal, you open parts of the assembly, only the public api should be tested.

Sometimes there are reasons why internal is okay because when you want to test full components which are e.g. in the di-infrastructure isolated behind an api.

Comment thread MORYX-Framework.slnx
@@ -1,186 +1,187 @@
<Solution>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here? Line endings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.