Skip to content

StackExchange.Redis.IDatabase mock requires more setup now #202

Closed
@dmytrostruk

Description

@dmytrostruk

NRedisStack Version: 0.10.0 or higher

Description:
Hi!
As soon as I update version of NRedisStack to 0.10.0 or higher, my unit tests with IDatabase mock are failing.

Previously, it was possible to mock IDatabase easier with:
mockDatabase.Setup(x => x.ExecuteAsync(...)).ReturnsAsync(...);

Now, it requires to mock not only ExecuteAsync method, but also:

  • IDatabase.Multiplexer
  • IConnectionMultiplexer.GetServer(...)
  • IConnectionMultiplexer.GetEndPoints()
  • IServer.Version.

I believe this is because of this line:

var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));

It was added in this PR:
https://github.com/redis/NRedisStack/pull/180/files#diff-325a736b58343c97ea736c8f94320677e56eb9eaa2f6b8152ca732e41f8fd197R76

If this is desired implementation, maybe it worth to mention this change as breaking one, so users will know that additional mock setup needs to be added, so it will be possible to test classes that have NRedisStack as dependency.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions