Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: moq/labs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 42c1375
Choose a base ref
...
head repository: moq/labs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7488d0f
Choose a head ref
  • 2 commits
  • 39 files changed
  • 2 contributors

Commits on Jan 20, 2018

  1. Add support for recursive mocks

    When doing `Setup(...)` we automatically setup a `SetupScope` which
    turns on the `RecursiveMockBehavior`'s automatic setup of null-valued
    returns just as you would have done if you had done
    `mock.RecursiveProp.Returns(Mock.Of<IRecursiveProp>)` followed by
    the actual setup of `mock.RecursiveProp.Name.Returns("foo")`.
    
    This can now be shrinked to `mock.Setup(x => x.RecursiveProp.Name).Returns("foo")`.
    
    Simplifying the detection of an active setup was simplified since the previous
    approach of making it per-mock (we were keeping a state flag in the mock itself)
    wouldn't work well in recursive mocks since you'd need to preserve that flag across
    mocks, and it wasn't really obvious how much benefit we were getting from making
    it per-mock as opposed to something like:
    
    ```c#
    using (Setup())
    {
      // Set up any number of mocks in a single block
    }
    ```
    
    So we enabled precisely that, by moving to a global per-execution context flag
    kept by an `AsyncLocal<T>` than can propagate threads.
    
    NOTE: we don't keep track of how many scopes have been created so far and
    which ones have been disposed to run off the `SetupScope.IsActive` flag.
    Doing so might be useful eventually, but it's better to keep the design simple
    for now since having multiple nested calls that would perform setups is
    likely quite a rare scenario anyway.
    kzu committed Jan 20, 2018
    Configuration menu
    Copy the full SHA
    5ad53dd View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2018

  1. Fix typos in comments

    stakx committed Jan 21, 2018
    Configuration menu
    Copy the full SHA
    7488d0f View commit details
    Browse the repository at this point in the history
Loading