public EitherAsync <Error, Player> Add(Player player) { return(_decoratee.Add(player) .Do(p => { _versionMap.RecordVersionChange(GetEntityId(p), p.Version); })); }
public override void RegisterScenarioDependencies(Container container) { base.RegisterScenarioDependencies(container); _queryMock = Substitute.For <IQuery <TenantId, List <PlayerDto> > >(); container.Register(() => _queryMock, Lifestyle.Scoped); _repoMock = Substitute.For <IPlayersRepository>(); _repoMock.Add(Arg.Any <Player>()) .Returns(ci => ci.Arg <Player>()) .AndDoes(ci => { _actualPlayer = ci.Arg <Player>(); }); _repoMock.Update(Arg.Any <Player>(), Arg.Any <Version>()) .Returns(ci => { var original = ci.Arg <Player>(); var updatedVersion = new Version($"updated-{original.Version}"); _versionMap.RecordVersionChange(this.GetEntityId(original), updatedVersion); var updated = new Player(original.Tenant, updatedVersion, original.Id, original.FirstName, original.LastName); return(updated); }) .AndDoes(ci => { if (_actualPlayer == null) { return; } _actualPlayer = ci.Arg <Player>(); }); container.Register(() => _repoMock, Lifestyle.Scoped); }