IntuneAppConfigurationPolicy: Fixed tests so that resource reports its correct state #4304
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.
Pull Request (PR) description
This PR fixes the way the tests are done in Test-TargetResource so that the resource reports its correct state, I might have been mistaken on #3542 where I say that the resource could be removed but actually it didn't but it reported that the resource was in correct state. I replaced the algorithm check the CustomSettings with a generic one that is already used in other resources and is known to work.
Additionally during Set it had to find the policy again multiple times because Id was not part of the resource so I added it in order to avoid doing all those retrievals, it first checks for the Id and if it cannot find it then searches by DisplayName as it does today.
This Pull Request (PR) fixes the following issues