dennisdoomen / dennisdoomen/fluentassertions.mockly

HaveBeenCalled(int) and HaveBeenCalledTimes(int) are duplicates of each other

Open
#77 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
0
Forks
0
Avg merge
11d 7h
Merged PRs (30d)
4

Description

## Problem

`RequestMockResponseBuilderAssertions` exposes two methods that do the same thing:

```csharp
public AndConstraint<...> HaveBeenCalled(int times, string because = "", params object[] becauseArgs);
public AndConstraint<...> HaveBeenCalledTimes(int expected, string because = "", params object[] becauseArgs);
```

Both validate the argument is non-negative, both compare `subject.RequestMock.InvocationCount` for exact equality, and both return the same constraint. The only difference is the failure wording:

- `HaveBeenCalled`: `"...but it was called {3} time(s)."`
- `HaveBeenCalledTimes`: `"...but it was invoked {3} time(s)."`

This looks like the result of the two parallel PRs that landed the per-mock invocation assertions (#32 and #36) both adding their own spelling.

## Why it matters

Two names for one concept is a discoverability tax: users have to wonder whether the difference is meaningful. It also means every future change (say, adding "at least"/"at most" semantics) has to be made twice.

## Proposal

Keep `HaveBeenCalled(int times)` — it reads better in a chain and pairs with the parameterless `HaveBeenCalled()` and with `NotHaveBeenCalled()`. Mark `HaveBeenCalledTimes` `[Obsolete]` pointing at it, and remove it in the next major.

Requires an `AcceptApiChanges.ps1` run for the approved-API files.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating RequestMockResponseBuilderAssertions and compare the two invocation assertion methods. Mark HaveBeenCalledTimes as obsolete in favor of HaveBeenCalled, then run AcceptApiChanges.ps1 and update the approved-API files. Done means the duplicate API is clearly deprecated and the approved API files reflect the change.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.