private void SetupServiceMock() { _serviceMock = Substitute.For <ICachingTestService>(); _serviceMock.CallService().Returns(_ => { return(Task.FromResult(_serviceResult)); }); _serviceMock.CallServiceWithAttRefreshTime().Returns(_ => { return(Task.FromResult(_serviceResult)); }); _serviceMock.CallServiceWithoutAttRefreshTime().Returns(_ => { return(Task.FromResult(_serviceResult)); }); _serviceMock.CallRevocableService(Arg.Any <string>()).Returns(async s => { var result = _serviceResult; await _revokeDelay; return(new Revocable <string> { Value = result, RevokeKeys = new[] { s.Args()[0].ToString() } }); }); _serviceResult = FirstResult; var serviceProxyMock = Substitute.For <IServiceProxyProvider <ICachingTestService> >(); serviceProxyMock.Client.Returns(_serviceMock); _kernel.Rebind <IServiceProxyProvider <ICachingTestService> >().ToConstant(serviceProxyMock); }
public void Setup() { SetupServiceMock(); SetupDateTime(); _proxy = _kernel.Get <ICachingTestService>(); }
private void SetupServiceMock() { _serviceMock = Substitute.For <ICachingTestService>(); _serviceMock.CallService().Returns(_ => Task.FromResult(_serviceResult)); _serviceResult = FirstResult; var serviceProxyMock = Substitute.For <IServiceProxyProvider <ICachingTestService> >(); serviceProxyMock.Client.Returns(_serviceMock); _kernel.Rebind <IServiceProxyProvider <ICachingTestService> >().ToConstant(serviceProxyMock); }
public void Setup() { SetupServiceMock(); SetupDateTime(); _revokeDelay = Task.Delay(0); _proxy = _kernel.Get <ICachingTestService>(); _cacheRevoker = _kernel.Get <ICacheRevoker>(); _revokeListener = _kernel.Get <IRevokeListener>(); }