Skip to content

Commit

Permalink
Refactor StackReferenceMock filtering in Mocks.cs
Browse files Browse the repository at this point in the history
Modified the filtering of StackReferenceMock instances in Mocks.cs in order to simplify and improve code readability. Refactored the two separate Where clauses into OfType<StackReferenceMock>() followed by a Where clause, which provides the same functionality but in a more clear and concise manner. Also removed redundant newlines at the end of the file.
  • Loading branch information
rexebin committed Feb 24, 2024
1 parent c688b67 commit 06d4f8c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions PulumiTestHelper/Internals/Mocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ private Dictionary<string, object> GetResourceMocks(MockResourceArgs args)
private void AddStackReferenceMocks(MockResourceArgs args, ImmutableDictionary<string, object>.Builder outputs)
{
var mocks = resourceMocks
.Where(x => x is StackReferenceMock)
.Where(x => ((StackReferenceMock) x).StackReferenceName == args.Name)
.Select(x => x.Mocks).DeepMergeMany();
.OfType<StackReferenceMock>()
.Where(x => x.StackReferenceName == args.Name)
.Select(x => x.Mocks)
.DeepMergeMany();

outputs.Add("secretOutputNames", new List<string>());
outputs.Add("outputs", mocks);
Expand All @@ -86,6 +87,4 @@ private Dictionary<string, object> GetCallMocks(MockCallArgs args)

return mocks.DeepMergeInto(mocksFromFunc);
}


}

0 comments on commit 06d4f8c

Please sign in to comment.